IHashCodeProvider IHashCodeProvider IHashCodeProvider IHashCodeProvider Interface

定義

警告

此 API 現已淘汰。

使用自訂雜湊函式,提供物件的雜湊程式碼。Supplies a hash code for an object, using a custom hash function.

public interface class IHashCodeProvider
[System.Obsolete("Please use IEqualityComparer instead.")]
[System.Runtime.InteropServices.ComVisible(true)]
public interface IHashCodeProvider
type IHashCodeProvider = interface
Public Interface IHashCodeProvider
衍生
屬性

備註

重要

我們不建議您針對新的IHashCodeProvider開發使用此介面。We don't recommend that you use the IHashCodeProvider interface for new development. 其建議的System.Collections.IEqualityComparer取代是或System.Collections.Generic.IEqualityComparer<T>介面。Its recommended replacement is the System.Collections.IEqualityComparer or System.Collections.Generic.IEqualityComparer<T> interface.

IHashCodeProvider介面會Hashtable與類別搭配使用。The IHashCodeProvider interface is used in conjunction with the Hashtable class. Hashtable物件當做索引鍵使用的物件必須覆Object.GetHashCode寫和Object.Equals方法。The objects used as keys by a Hashtable object must override the Object.GetHashCode and Object.Equals methods. Object.GetHashCode或金鑰的執行Object.GetHashCode會當做雜湊碼提供者使用。Object.GetHashCode or the key's implementation of Object.GetHashCode is used as the hash code provider. Object.Equals或金鑰的執行Object.Equals會當做比較子使用。Object.Equals or the key's implementation of Object.Equals is used as the comparer.

不過, 此Hashtable函式IHashCodeProvider的某些多載會採用一個實作為執行的參數, 或是一個執行IComparer的參數, 或兩者。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. 如果將IHashCodeProvider實值傳遞給此函式IHashCodeProvider.GetHashCode , 則會使用該實作為雜湊碼提供者的方法。If an IHashCodeProvider implementation is passed to the constructor, the IHashCodeProvider.GetHashCode method of that implementation is used as the hash code provider. 如果將IComparer實作為傳遞給此函式IComparer.Compare , 則會使用該實作為比較子的方法。If an IComparer implementation is passed to the constructor, the IComparer.Compare method of that implementation is used as the comparer.

方法

GetHashCode(Object) GetHashCode(Object) GetHashCode(Object) GetHashCode(Object)

傳回指定物件的雜湊碼。Returns a hash code for the specified object.

適用於

另請參閱