Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IHashCodeProvider Interface

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

obsoleteCodeEntityT:System.Collections.IEqualityComparerNote: This API is now obsolete.

Supplies a hash code for an object, using a custom hash function.

Namespace:   System.Collections
Assembly:  mscorlib (in mscorlib.dll)

[ObsoleteAttribute("Please use IEqualityComparer instead.")]
[ComVisibleAttribute(true)]
public interface IHashCodeProvider

NameDescription
System_CAPS_pubmethodGetHashCode(Object)

Returns a hash code for the specified object.

The IHashCodeProvider interface is used in conjunction with the Hashtable class. The objects used as keys by a Hashtable object must override the Object.GetHashCode and Object.Equals methods. Object.GetHashCode or the key's implementation of Object.GetHashCode is used as the hash code provider. Object.Equals or the key's implementation of Object.Equals is used as the comparer.

However, some overloads of the Hashtable constructor take a parameter that is an IHashCodeProvider implementation, or a parameter that is an IComparer implementation, or both. If an IHashCodeProvider implementation is passed to the constructor, the IHashCodeProvider.GetHashCode method of that implementation is used as the hash code provider. If an IComparer implementation is passed to the constructor, the IComparer.Compare method of that implementation is used as the comparer.

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft