string.ToLower()和string.ToLowerInvariant() [英] string.ToLower() and string.ToLowerInvariant()

查看:1745
本文介绍了string.ToLower()和string.ToLowerInvariant()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么区别,什么时候用什么?什么是风险,如果我总是用TOLOWER(),什么是如果我总是用ToLowerInvariant风险()?

What's the difference and when to use what? What's the risk if I always use ToLower() and what's the risk if I always use ToLowerInvariant()?

推荐答案

根据当前的文化,TOLOWER可能会产生一种文化特定的小写字母,你是不是期待。如生产信息不点上我,而不是信息,从而哉了字符串比较。出于这个原因,ToLowerInvariant应使用于任何非特定语言数据。当你可能有,可能是他们的母语/字符集的用户输入,一般应使用TOLOWER唯一的一次。

Depending on the current culture, ToLower might produce a culture specific lowercase letter, that you aren't expecting. Such as producing ınfo without the dot on the i instead of info and thus mucking up string comparisons. For that reason, ToLowerInvariant should be used on any non-language-specific data. When you might have user input that might be in their native language/character-set, would generally be the only time you use ToLower.

有关此问题的一个例子来看看这个问题: C# - TOLOWER()有时由字母QUOT去除斑点; I"

See this question for an example of this issue: C#- ToLower() is sometimes removing dot from the letter "I"

这篇关于string.ToLower()和string.ToLowerInvariant()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆