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 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.