Mono Class Library: System.Collections.Generic.IEqualityComparer<T> Overview | Members

System.Collections.Generic.IEqualityComparer<T>.GetHashCode Method

Returns a hash code for the specified object. [Edit]

public int GetHashCode (T obj)

Parameters

obj
The object for which the hash code is to be returned. [Edit]

Returns

A hash code for the specified object. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionThe type of obj is a reference type and obj is null. [Edit]

Remarks

To produce a hash function for the given object.

Note: A hash function is used to quickly generate a number (a hash code) corresponding to the value of an object. Hash functions are used with hashtables. A good hash function algorithm rarely generates hash codes that collide. For more information about hash functions, see The Art of Computer Programming , Vol. 3, by Donald E. Knuth.

Operation

All implementations are required to ensure that if x.Equals(y) == true, then x.GetHashCode() equals y.GetHashCode(), for any x and y values for which these expressions are defined.

[Edit]

Requirements

Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0