IHashCodeProvider.GetHashCode 方法

返回指定对象的哈希代码。

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

语法

声明
Function GetHashCode ( _
    obj As Object _
) As Integer
用法
Dim instance As IHashCodeProvider
Dim obj As Object
Dim returnValue As Integer

returnValue = instance.GetHashCode(obj)
int GetHashCode (
    Object obj
)
int GetHashCode (
    Object^ obj
)
int GetHashCode (
    Object obj
)
function GetHashCode (
    obj : Object
) : int

参数

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

返回值

指定对象的哈希代码。

异常

异常类型 条件

ArgumentNullException

obj 的类型为引用类型,obj 为 空引用(在 Visual Basic 中为 Nothing)。

备注

该方法的返回值决不能持久,有两个原因。首先,可能改变类的哈希函数以生成一个更好的分布,并使旧哈希函数中的所有值都无用。其次,该类的默认实现不保证不同的实例返回相同的值。

平台

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

请参见

参考

IHashCodeProvider 接口
IHashCodeProvider 成员
System.Collections 命名空间
Object.GetHashCode