UTF8Encoding.GetHashCode 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回目前執行個體的雜湊碼。
public:
override int GetHashCode();
public override int GetHashCode ();
override this.GetHashCode : unit -> int
Public Overrides Function GetHashCode () As Integer
傳回
目前執行個體的雜湊碼。
範例
下列範例會 GetHashCode 使用 方法傳回 實例的 UTF8Encoding 雜湊碼。 請注意,這個方法傳回的雜湊碼取決於用來建立物件的 UTF8Encoding 建構函式。
using namespace System;
using namespace System::Text;
int main()
{
// Many ways to instantiate a UTF8 encoding.
UTF8Encoding^ UTF8a = gcnew UTF8Encoding;
Encoding^ UTF8b = Encoding::UTF8;
Encoding^ UTF8c = gcnew UTF8Encoding( true,true );
Encoding^ UTF8d = gcnew UTF8Encoding( false,false );
// But not all are the same.
Console::WriteLine( UTF8a->GetHashCode() );
Console::WriteLine( UTF8b->GetHashCode() );
Console::WriteLine( UTF8c->GetHashCode() );
Console::WriteLine( UTF8d->GetHashCode() );
}
using System;
using System.Text;
class UTF8EncodingExample {
public static void Main() {
// Many ways to instantiate a UTF8 encoding.
UTF8Encoding UTF8a = new UTF8Encoding();
Encoding UTF8b = Encoding.UTF8;
Encoding UTF8c = new UTF8Encoding(true, true);
Encoding UTF8d = new UTF8Encoding(false, false);
// But not all are the same.
Console.WriteLine(UTF8a.GetHashCode());
Console.WriteLine(UTF8b.GetHashCode());
Console.WriteLine(UTF8c.GetHashCode());
Console.WriteLine(UTF8d.GetHashCode());
}
}
Imports System.Text
Class UTF8EncodingExample
Public Shared Sub Main()
' Many ways to instantiate a UTF8 encoding.
Dim UTF8a As New UTF8Encoding()
Dim UTF8b As Encoding = Encoding.UTF8
Dim UTF8c = New UTF8Encoding(True, True)
Dim UTF8d = New UTF8Encoding(False, False)
' But not all are the same.
Console.WriteLine(UTF8a.GetHashCode())
Console.WriteLine(UTF8b.GetHashCode())
Console.WriteLine(UTF8c.GetHashCode())
Console.WriteLine(UTF8d.GetHashCode())
End Sub
End Class