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.
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.