Redigera

Dela via


EqualityComparer<T>.GetHashCode(T) Method

Definition

When overridden in a derived class, serves as a hash function for the specified object for hashing algorithms and data structures, such as a hash table.

public:
 abstract int GetHashCode(T obj);
public abstract int GetHashCode (T obj);
override this.GetHashCode : 'T -> int
Public MustOverride Function GetHashCode (obj As T) As Integer

Parameters

obj
T

The object for which to get a hash code.

Returns

A hash code for the specified object.

Implements

Exceptions

The type of obj is a reference type and obj is null.

Notes to Implementers

Implementations are required to ensure that if the Equals(T, T) method returns true for two objects x and y, then the value returned by the GetHashCode(T) method for x must equal the value returned for y.

Applies to