See Also: CompareInfo Members
The System.Globalization.CultureInfo class includes a CultureInfo.CompareInfo property that is an instance of this class. string.Compare(string, string) uses the information in CultureInfo.CompareInfo to compare strings.
System.Globalization.CompareInfo provides the CompareInfo.GetCompareInfo(int, System.Reflection.Assembly) method, instead of public constructors, to allow for late-bound access.
To create a System.Globalization.CompareInfo object for any culture, you should use the CultureInfo.CompareInfo property, or call the CompareInfo.GetCompareInfo(int, System.Reflection.Assembly) method.
Comparison operations, such as those performed by the erload:System.Globalization.CompareInfo.IndexOf or erload:System.Globalization.CompareInfo.LastIndexOf methods, can yield unexpected results if the value to search for is ignored. The search value is ignored if it is an empty string (""), a character or string consisting of characters having code points that are not considered in the operation because of comparison options, or a value with code points that have no linguistic significance. If the search value for the erload:System.Globalization.CompareInfo.IndexOf method is an empty string, for example, the return value is zero.
If a security decision depends on a string comparison or a case change, you should use the CultureInfo.InvariantCulture to ensure that the behavior is consistent, regardless of the culture settings of the operating system.
When possible, you should use string comparison methods that have a parameter of type System.Globalization.CompareOptions to specify the kind of comparison expected. As a general rule, use linguistic options (using the current culture) for comparing strings displayed in the user interface and specify CompareOptions.Ordinal or CompareOptions.OrdinalIgnoreCase for security comparisons.