Namespace:
System.Collections.Generic
Assembly:
mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
<SerializableAttribute> _
Public MustInherit Class Comparer(Of T) _
Implements IComparer, IComparer(Of T)
Dim instance As Comparer(Of T)
[SerializableAttribute]
public abstract class Comparer<T> : IComparer,
IComparer<T>
[SerializableAttribute]
generic<typename T>
public ref class Comparer abstract : IComparer,
IComparer<T>
JScript does not support generic types or methods.
Type Parameters
- T
The type of objects to compare.
Derive from this class to provide a custom implementation of the IComparer<(Of <(T>)>) interface for use with collection classes such as the SortedList<(Of <(TKey, TValue>)>) and SortedDictionary<(Of <(TKey, TValue>)>) generic classes.
The object returned by the Default property uses the System..::.IComparable<(Of <(T>)>) generic interface (IComparable<T> in C#, IComparable(Of T) in Visual Basic) to compare two objects. If type T does not implement the System..::.IComparable<(Of <(T>)>) generic interface, the Default property returns a Comparer<(Of <(T>)>) that uses the System..::.IComparable interface.
Notes to Implementers:
Compare and EqualityComparer<(Of <(T>)>)..::.Equals may behave differently in terms of culture-sensitivity and case-sensitivity.
For string comparisons, the StringComparer class is recommended over Comparer<String>. Properties of the StringComparer class return predefined instances that perform string comparisons with different combinations of culture-sensitivity and case-sensitivity. The case-sensitivity and culture-sensitivity are consistent among the members of the same StringComparer instance.
For more information on culture-specific comparisons, see the System.Globalization namespace and Encoding and Localization.
System..::.Object
System.Collections.Generic..::.Comparer<(Of <(T>)>)
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0
.NET Compact Framework
Supported in: 3.5, 2.0
XNA Framework
Supported in: 3.0, 2.0, 1.0
Reference