我的ASP.NET MVC应用程序中有以下C#代码。我尝试使用Equals方法与culture = "vi"比较2个string。我的代码如下:
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。有谁能帮帮我呢?
发布于 2017-09-25 15:16:51
在越南语的情况下,它是不等于GI的gI。gi (GI)是音节的首字母,有点像一个字母,而gI是两个独立的字母。其他配对包括
cH != CH
kH != KH
nG != NG
nH != NH
pH != PH
qU != QU
tH != TH
tR != TR发布于 2017-09-25 15:21:22
你可以试试
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将返回false。根据您的文化,GID和gId是不同的。
https://stackoverflow.com/questions/46399390
复制相似问题