IEqualityComparer IEqualityComparer IEqualityComparer IEqualityComparer Interface

定义

定义方法以支持对象的相等比较。Defines methods to support the comparison of objects for equality.

public interface class IEqualityComparer
[System.Runtime.InteropServices.ComVisible(true)]
public interface IEqualityComparer
type IEqualityComparer = interface
Public Interface IEqualityComparer
派生
属性

注解

此接口允许实现集合的自定义相等性比较。This interface allows the implementation of customized equality comparison for collections. 也就是说, 你可以创建你自己的相等性定义, 并指定此定义与接受该IEqualityComparer接口的集合类型一起使用。That is, you can create your own definition of equality, and specify that this definition be used with a collection type that accepts the IEqualityComparer interface. 在 .NET Framework 中,、和Hashtable OrderedDictionary集合类型NameValueCollection的构造函数接受此接口。In the .NET Framework, constructors of the Hashtable, NameValueCollection, and OrderedDictionary collection types accept this interface.

有关此接口的泛型版本, 请参阅System.Collections.Generic.IEqualityComparer<T>For the generic version of this interface, see System.Collections.Generic.IEqualityComparer<T>.

IEqualityComparer接口仅支持相等比较。The IEqualityComparer interface supports only equality comparisons. 排序和排序比较的自定义是由IComparer接口提供的。Customization of comparisons for sorting and ordering is provided by the IComparer interface.

方法

Equals(Object, Object) Equals(Object, Object) Equals(Object, Object) Equals(Object, Object)

确定指定的对象是否相等。Determines whether the specified objects are equal.

GetHashCode(Object) GetHashCode(Object) GetHashCode(Object) GetHashCode(Object)

返回指定对象的哈希代码。Returns a hash code for the specified object.

适用于

另请参阅