public interface IHashCodeProvider
mscorlib
BCL
Implemented by classes that support custom hash functions for instances of the class.
[Note: IHashCodeProvider contains the System.Collections.IHashCodeProvider.GetHashCode(System.Object) method. The consumer of an object should call this method to obtain a hash code for the object using a custom hash function.]
System.Collections Namespace
IHashCodeProvider Methods
int GetHashCode(object obj);
Generates a hash code for the specified Object.
- obj
- The Object for which a hash code is to be generated.
A Int32 containing the hash code for the specified Object.
Exception Type Condition ArgumentNullException obj is null
.
[Behaviors: If obj isnull
, it is required that a call to System.Collections.IHashCodeProvider.GetHashCode(System.Object) throw ArgumentNullException.]
[Overrides: 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 may 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.]
System.Collections.IHashCodeProvider Interface, System.Collections Namespace