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.
.NET FrameworkSupported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
Supported in: Windows Phone 8.1
Supported in: Windows Phone Silverlight 8.1
Supported in: Windows Phone Silverlight 8
Windows Phone 8.1, Windows Phone 8, 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)