注意:此接口在 .NET Framework 2.0 版中是新增的。
定义类型为比较两个对象而实现的方法。
命名空间:System.Collections.Generic
程序集:mscorlib(在 mscorlib.dll 中)
Public Interface IComparer(Of T)
Dim instance As IComparer(Of T)
public interface IComparer<T>
generic<typename T>
public interface class IComparer
J# 支持使用泛型类型和方法,但不支持进行新的声明。
类型参数
- T
要比较的对象的类型。
此接口由 System.Collections.Generic.List.Sort 和 System.Collections.Generic.List.BinarySearch 方法使用。它提供一种自定义集合排序顺序的方法。实现此接口的类包括 SortedDictionary 和 SortedList 泛型类。
此接口的默认实现为 Comparer 类。StringComparer 类为 String 类型实现此接口。
此接口支持排序比较。也就是说,当 Compare 方法返回 0 时,即表示两个对象的排序相同。完全相等比较的实现由 IEqualityComparer 泛型接口提供。
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
.NET Framework
受以下版本支持:2.0
.NET Compact Framework
受以下版本支持:2.0