且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

忽略大小写和比较C#

更新时间:2023-02-20 07:57:17

使用这样的:

  VAR的结果=的String.Compare(AA,AA,StringComparison.OrdinalIgnoreCase);
 

的String.Compare方法(字符串,字符串,布尔)

How to convert the string to uppercase before performing a compare, or is it possible to compare the string by ignoring the case

 if (Convert.ToString(txt_SecAns.Text.Trim()).ToUpper() == 
     Convert.ToString(hidden_secans.Value).ToUpper())

use this:

var result = String.Compare("AA", "aa", StringComparison.OrdinalIgnoreCase);

String.Compare Method (String, String, Boolean)