Mono Class Library: System.Collections.IHashCodeProvider Overview | Members

System.Collections.IHashCodeProvider.GetHashCode Method

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

public int GetHashCode (object obj)

Parameters

obj
The object for which a hash code is to be generated. [Edit]

Returns

A int containing the hash code for the specified object. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionobj is null. [Edit]

Remarks

Operation
If obj is null, it is required that a call to IHashCodeProvider.GetHashCode(object) throw ArgumentNullException.

Note to Inheritors
Implement this method to generate a better hash table distribution than the default method provided by the type of the object for which the hash code is being generated.

Usage
The value returned by this method should not be persisted past the lifetime of the application that created the value. The first reason is that the hash function of a class might be altered to generate a better distribution, rendering any values from the old hash function useless. The second reason is that the default implementation of this class does not guarantee that the same value will be returned by different instances.

[Edit]

Requirements

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0