Derive from this class to provide a custom implementation of the IComparer interface for use with collection classes such as the SortedList and SortedDictionary generic classes.
The object returned by the Default property uses the System.IComparable generic interface (IComparable<T> in C#, IComparable(Of T) in Visual Basic) to compare two objects. If type T does not implement the System.IComparable generic interface, the Default property returns a Comparer that uses the System.IComparable interface.
Notes to Implementers: Compare and
EqualityComparer.Equals may behave differently in terms of culture-sensitivity and case-sensitivity.
For string comparisons, the
StringComparer class is recommended over
Comparer<String>. Properties of the
StringComparer class return predefined instances that perform string comparisons with different combinations of culture-sensitivity and case-sensitivity. The case-sensitivity and culture-sensitivity are consistent among the members of the same
StringComparer instance.
For more information on culture-specific comparisons, see the
System.Globalization namespace and
Encoding and Localization.