Defines a method that a type implements to compare two objects.
Assembly: mscorlib (in mscorlib.dll)
- in T
The type of objects to compare.
This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
Thetype exposes the following members.
This interface is used with the List(T).Sort and List(T).BinarySearch methods. It provides a way to customize the sort order of a collection. Classes that implement this interface include the SortedDictionary(TKey, TValue) and SortedList(TKey, TValue) generic classes.
This interface supports ordering comparisons. That is, when the Compare method returns 0, it means that two objects sort the same. Implementation of exact equality comparisons is provided by the IEqualityComparer(T) generic interface.
We recommend that you derive from the Comparer(T) class instead of implementing the interface, because the Comparer(T) class provides an explicit interface implementation of the IComparer.Compare method and the Default property that gets the default comparer for the object.