System.Collections.Generic.Comparer<T> Class

Provides a base class for implementations of the IComparer`1 generic interface.

See Also: Comparer<T> Members


public abstract class Comparer<T> : IComparer<T>, IComparer

Type Parameters

Documentation for this section has not yet been entered.


Derive from this class to provide a custom implementation of the IComparer`1 interface for use with collection classes such as the SortedList`2 and SortedDictionary`2 generic classes.

The difference between deriving from the Comparer`1 class and implementing the IComparable interface is as follows:

The object returned by the Comparer`1.Default property uses the IComparable`1 generic interface (IComparable<T> in C#, IComparable(Of T) in Visual Basic) to compare two objects. If type T does not implement the IComparable`1 generic interface, the Comparer`1.Default property returns a Comparer`1 that uses the IComparable interface.


Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0