当比较在C#中的平等两个字符串,什么是InvariantCulture的和有序的比较有什么区别?
When comparing two strings in c# for equality, what is the difference between InvariantCulture and Ordinal comparison?
在InvariantCulture的设置使用标准设定的字符排序(A,B,C,...等)。这是相对于一些特定的区域设置,其可排序以不同的顺序字符('一个与 - 急性'可以是之前的的或的后一,取决于区域设置,等等)。
The "InvariantCulture" setting uses a "standard" set of character orderings (a,b,c, ... etc.). This is in contrast to some specific locales, which may sort characters in different orders ('a-with-acute' may be before or after 'a', depending on the locale, and so on).
序号的比较,在另一方面,相貌纯粹在的原始字节(s)表示重新present字符的值。有一个很大的样品在http://msdn.microsoft.com/en-us/library/e6883c06.aspx显示的各种StringComparison值的结果。一路到了最后,这表明(摘录):
"Ordinal" comparison, on the other hand, looks purely at the values of the raw byte(s) that represent the character. There's a great sample at http://msdn.microsoft.com/en-us/library/e6883c06.aspx that shows the results of the various StringComparison values. All the way at the end, it shows (excerpted):
StringComparison.InvariantCulture:
LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER DOTLESS I (U+0131)
LATIN SMALL LETTER I (U+0069) is less than LATIN CAPITAL LETTER I (U+0049)
LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN CAPITAL LETTER I (U+0049)
StringComparison.Ordinal:
LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER DOTLESS I (U+0131)
LATIN SMALL LETTER I (U+0069) is greater than LATIN CAPITAL LETTER I (U+0049)
LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN CAPITAL LETTER I (U+0049)
您可以看到,在这里InvariantCulture的收益率(U + 0069,U + 0049,U + 00131),序号收益率(U + 0049,U + 0069,U + 00131)。
You can see that where InvariantCulture yields (U+0069, U+0049, U+00131), Ordinal yields (U+0049, U+0069, U+00131).
上一篇:是否有替代混蛋注射? (男子AKA可怜的注射通过默认构造函数)混蛋、函数、男子、AKA
下一篇:Server.UrlEn code与HttpUtility.UrlEn codeUrlEn、Server、HttpUtility、code