Hashtable.GetHash 方法

返回指定键的哈希代码。

**命名空间:**System.Collections
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Protected Overridable Function GetHash ( _
    key As Object _
) As Integer
用法
Dim key As Object
Dim returnValue As Integer

returnValue = Me.GetHash(key)
protected virtual int GetHash (
    Object key
)
protected:
virtual int GetHash (
    Object^ key
)
protected int GetHash (
    Object key
)
protected function GetHash (
    key : Object
) : int

参数

  • key
    Object,将为其返回哈希代码。

返回值

key 的哈希代码。

异常

异常类型 条件

NullReferenceException

key 为 空引用(在 Visual Basic 中为 Nothing)。

备注

如果该哈希表是使用特定的 IHashCodeProvider 实现创建的,则此方法使用该哈希代码提供程序;否则它使用 key 的 Object.GetHashCode 实现。

此方法是 O(1) 操作。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Hashtable 类
Hashtable 成员
System.Collections 命名空间
Object.GetHashCode
Object 类
IHashCodeProvider