IStructuralEquatable.GetHashCode(IEqualityComparer) Method

Definition

返回当前实例的哈希代码。Returns a hash code for the current instance.

public:
 int GetHashCode(System::Collections::IEqualityComparer ^ comparer);
public int GetHashCode (System.Collections.IEqualityComparer comparer);
abstract member GetHashCode : System.Collections.IEqualityComparer -> int
Public Function GetHashCode (comparer As IEqualityComparer) As Integer

Parameters

comparer
IEqualityComparer

一个计算当前对象的哈希代码的对象。An object that computes the hash code of the current object.

Returns

Int32

当前实例的哈希代码。The hash code for the current instance.

Remarks

实现此方法可为集合对象返回自定义的哈希代码,这些对象对应于由 Equals 方法提供的结构相等性的自定义比较。Implement this method to return customized hash codes for collection objects that correspond to the customized comparison for structural equality provided by the Equals method.

Notes to Implementers

如果 Equals(Object, IEqualityComparer) 方法返回两个对象 true,则两个对象的 GetHashCode(IEqualityComparer) 方法返回的值也必须相等。If the Equals(Object, IEqualityComparer) method returns true for two objects, the values returned by the GetHashCode(IEqualityComparer) method for the two objects must also be equal.

Applies to