Assembly: mscorlib (in mscorlib.dll)
|Compare strings using culture-sensitive sort rules and the current culture.|
|Compare strings using culture-sensitive sort rules, the current culture, and ignoring the case of the strings being compared.|
|Compare strings using culture-sensitive sort rules and the invariant culture.|
|Compare strings using culture-sensitive sort rules, the invariant culture, and ignoring the case of the strings being compared.|
|Compare strings using ordinal sort rules.|
|Compare strings using ordinal sort rules and ignoring the case of the strings being compared.|
The enumeration is used to specify whether a string comparison should use the current culture or the invariant culture, word or ordinal sort rules, and be case-sensitive or case-insensitive.
When you call a string comparison method such as String::Compare, String::Equals, or String::IndexOf, you should always call an overload that includes a parameter of type so that you can specify the type of comparison that the method performs. For more information, see Best Practices for Using Strings in the .NET Framework.
An operation that uses word sort rules performs a culture-sensitive comparison wherein certain nonalphanumeric Unicode characters might have special weights assigned to them. Using word sort rules and the conventions of a specific culture, the hyphen ("-") might have a very small weight assigned to it so that "coop" and "co-op" appear next to each other in a sorted list.
An operation that uses ordinal sort rules performs a comparison based on the numeric value (Unicode code point) of each Char in the string. An ordinal comparison is fast but culture-insensitive. When you use ordinal sort rules to sort strings that start with Unicode characters (U+), the string U+xxxx comes before the string U+yyyy if the value of xxxx is numerically less than yyyy.
For more information about comparisons, see the System::String class remarks. For more information about culture, see the System.Globalization::CultureInfo class remarks. For guidelines on when to use ordinal or culture-sensitive comparison rules or the rules of the invariant culture, see Best Practices for Using Strings in the .NET Framework.
The following example compares four sets of words by using each member of the enumeration. The comparisons use the conventions of the English (United States) and Sami (Upper Sweden) cultures. Note that the strings "encyclopædia" and "encyclopedia" are considered equivalent in the en-US culture but not in the Sami (Northern Sweden) culture.
.NET FrameworkSupported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
.NET for Windows Phone appsSupported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.