[英]String.Equals GID returning false?
我的ASP.NET MVC應用程序中有以下C#代碼。 我嘗試使用Equals
方法比較2個string
,其中culture = "vi"
。 我的代碼如下:
string culture = "vi";
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
System.Threading.Thread.CurrentThread.CurrentUICulture =
System.Threading.Thread.CurrentThread.CurrentCulture;
var CCC = string.Equals("CategId", "CATEGID", StringComparison.CurrentCultureIgnoreCase);
var xx = string.Equals("TestGID", "TestGID", StringComparison.CurrentCultureIgnoreCase);
var zz = string.Equals("id", "ID", StringComparison.CurrentCultureIgnoreCase);
結果:
CCC = false ;
xx = true;
zz = true;
我不知道為什么CCC
是false
。 有什么不對的嗎? 如果我設置culture = id, ko, en
等...那么CCC = true
。 誰能幫我?
在越南語的情況下, gI
不等於GI
。 gi
( GI
)是音節 - 首字母,一種字母,而gI
是兩個單獨的字母。 其他對是
cH != CH
kH != KH
nG != NG
nH != NH
pH != PH
qU != QU
tH != TH
tR != TR
你可以試試
string culture = "vi";
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
System.Threading.Thread.CurrentThread.CurrentUICulture =
System.Threading.Thread.CurrentThread.CurrentCulture;
var CCC = string.Equals("CategId", "CATEGID", StringComparison.InvariantCultureIgnoreCase);
var CCC1 = string.Equals("CategId", "CATEGID", StringComparison.CurrentCultureIgnoreCase);
在這個CCC
將返回true
但CCC1
將因Culture而返回false
。 根據你的文化GID
和gId
是不同的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.