Hashtable.GetHash(Object) 方法

定义

返回指定键的哈希代码。Returns the hash code for the specified key.

protected:
 virtual int GetHash(System::Object ^ key);
protected virtual int GetHash (object key);
abstract member GetHash : obj -> int
override this.GetHash : obj -> int
Protected Overridable Function GetHash (key As Object) As Integer

参数

key
Object

Object,将为其返回哈希代码。The Object for which a hash code is to be returned.

返回

key 的哈希代码。The hash code for key.

异常

keynullkey is null.

注解

如果哈希表是使用特定 @no__t 0 实现创建的,则此方法将使用该哈希代码提供程序;否则,它将使用第 2 @no__t 实现 @no__t。If the hash table was created with a specific IHashCodeProvider implementation, this method uses that hash code provider; otherwise, it uses the Object.GetHashCode implementation of key.

此方法是 @no__t 0 操作。This method is an O(1) operation.

适用于

另请参阅