CompilerInfo.GetHashCode 方法

定义

返回当前实例的哈希代码。

public:
 override int GetHashCode();
public override int GetHashCode();
override this.GetHashCode : unit -> int
Public Overrides Function GetHashCode () As Integer

返回

当前 CompilerInfo 实例的 32 位有符号整数哈希代码,适用于哈希算法和数据结构,例如哈希表。

示例

下面的代码示例创建类的 Microsoft.VisualBasic.VBCodeProvider 实例。 该示例显示新提供程序实例的提供程序名称、哈希代码和默认文件扩展名。 该代码示例是 CompilerInfo 类中的一个较大示例的一部分。

// Get the provider for Microsoft.VisualBasic
CodeDomProvider provider = CodeDomProvider.CreateProvider("VisualBasic");

// Display the Visual Basic language provider information.
Console.WriteLine("Visual Basic provider is {0}",
    provider.ToString());
Console.WriteLine("  Provider hash code:     {0}",
    provider.GetHashCode().ToString());
Console.WriteLine("  Default file extension: {0}",
    provider.FileExtension);
' Get the provider for Microsoft.VisualBasic
   Dim provider = CodeDomProvider.CreateProvider("VisualBasic")

' Display the Visual Basic language provider information.
Console.WriteLine("Visual Basic provider is {0}", _
   provider.ToString())
Console.WriteLine("  Provider hash code:     {0}", _
   provider.GetHashCode().ToString())
Console.WriteLine("  Default file extension: {0}", _
   provider.FileExtension)

注解

此方法替代 Object.GetHashCode 该方法。

此方法为两个对象生成相同的哈希代码,这些对象根据 Equals 该方法相等。

适用于

另请参阅