我们注意到在某些字符串上调用 ToLower() 时出现奇怪的错误。
输入的字符串是:
string s = "DocumentInfo";
string t = s.ToLower();
// sometimes, t == documentinfo
// other times, t == documentınfo (note dot is missing from i - INCORRECT)
我们将字符串传递给下游的 Web 服务查询,因此它给我们带来了问题。
我最初的猜测是它与 Culture 或 UICulture 有关,因为我们的一些页面会为每个用户自定义这些设置。
这会是问题所在吗?有什么方法可以强制它正常工作吗?
更新 2011.07.06
我发现我可以通过将 Culture 设置为 tr-TR 来重现该问题。 不确定其他文化是否受到影响。
最佳答案
尝试使用 String.ToLowerInvariant()
.
关于C#- ToLower() 有时会从字母 "I"中删除点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6600954/