Bewerken

Share via


IHashCodeProvider Interface

Definition

Caution

Please use IEqualityComparer instead.

Caution

IHashCodeProvider has been deprecated. Use IEqualityComparer instead.

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

public interface class IHashCodeProvider
[System.Obsolete("Please use IEqualityComparer instead.")]
public interface IHashCodeProvider
[System.Obsolete("IHashCodeProvider has been deprecated. Use IEqualityComparer instead.")]
public interface IHashCodeProvider
public interface IHashCodeProvider
[System.Obsolete("Please use IEqualityComparer instead.")]
[System.Runtime.InteropServices.ComVisible(true)]
public interface IHashCodeProvider
[<System.Obsolete("Please use IEqualityComparer instead.")>]
type IHashCodeProvider = interface
[<System.Obsolete("IHashCodeProvider has been deprecated. Use IEqualityComparer instead.")>]
type IHashCodeProvider = interface
type IHashCodeProvider = interface
[<System.Obsolete("Please use IEqualityComparer instead.")>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type IHashCodeProvider = interface
Public Interface IHashCodeProvider
Derived
Attributes

Remarks

Important

We don't recommend that you use the IHashCodeProvider interface for new development. Its recommended replacement is the System.Collections.IEqualityComparer or System.Collections.Generic.IEqualityComparer<T> interface.

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.

Methods

GetHashCode(Object)

Returns a hash code for the specified object.

Applies to

See also