· Use StringComparison.Ordinalor StringComparison.OrdinalIgnoreCase forcomparisons as your safe default for culture-agnostic string matching.
通过StringComparison明确指明是否区分大小(而不是使用默认的,默认的规则在各个类里可能并不一致)· Use comparisons with StringComparison.Ordinalor StringComparison.OrdinalIgnoreCase forbetter performance.
· Use string operations that are based on StringComparison.CurrentCulture when you displayoutput to the user.
如果相应的字符串会显示给用户,那么使用基于StringComparison.CurrentCulture的字符串操作 //z 2012-2-7 16:50:57 PM IS2120@CSDN· Use the non-linguistic StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase values insteadof string operations based onwhen the comparison is linguistically irrelevant (symbolic, for example).
如果比较是语言学无关的,使用StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase (效率会更高?),而不是· Use the method instead of the method when you normalize strings for comparison.
推荐使用 而不是· Use an overload of the method to test whether two strings are equal.
使用string.equals的重载方法测试两个string是否一致。· Use and to sort strings, not to check for equality.
将Compare和CompareTo用于对字符串进行排序,而非用于一致性检查Avoid the following practices when you use strings:
· Do not use overloads that do not explicitly orimplicitly specify the string comparison rules for string operations.
不要使用那些没有或明或暗指定比较规则的字符串操作函数· Do not use string operations based on StringComparison.InvariantCulture in most cases.One of the few exceptions is when you are persisting linguistically meaningfulbut culturally agnostic data.
//z 2012-2-7 16:50:57 PM IS2120@CSDN在大多数时候都不要使用基于StringComparison.InvariantCulture的函数。· Do not use an overload of the or method and test for a return value of zero to determine whether two strings areequal.
不得使用String.Compare或是CompareTo通过测试返回值是否为0来判断两个字符串是否相等。//z 2012-2-7 16:50:57 PM IS2120@CSDN