Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
下面的代码不应该返回 4 吗?它正在返回-1
string sa = "soy mas grande"; Response.Write("CMP: "+sa.IndexOf("más", StringComparison.InvariantCulture)+"<br>");
StringComparison.InvariantCulture不会去除口音,您可能正在寻找这个:
StringComparison.InvariantCulture
System.Globalization.CultureInfo.InvariantCulture .CompareInfo.IndexOf(sa, "más", System.Globalization.CompareOptions.IgnoreNonSpace)
不; “más”不是“mas”,所以它不会匹配。