Freigeben über


UTF8Encoding.GetHashCode-Methode

Gibt den Hashcode für die aktuelle Instanz zurück.

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overrides Function GetHashCode As Integer
'Usage
Dim instance As UTF8Encoding
Dim returnValue As Integer

returnValue = instance.GetHashCode
public override int GetHashCode ()
public:
virtual int GetHashCode () override
public int GetHashCode ()
public override function GetHashCode () : int

Rückgabewert

Der Hashcode für die aktuelle Instanz.

Beispiel

Im folgenden Beispiel wird veranschaulicht, wie mit der GetHashCode-Methode ein Hashcode für eine Instanz von UTF8Encoding zurückgegeben wird. Beachten Sie, dass der von dieser Methode zurückgegebene Hashcode von dem Konstruktor abhängt, der zum Erstellen von UTF8Encoding verwendet wird.

Imports System
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 'Main
End Class 'UTF8EncodingExample
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());
    }
}
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() );
}
import System.*;
import System.Text.*;

class UTF8EncodingExample
{
    public static void main(String[] args)
    {
        // Many ways to instantiate a UTF8 encoding.
        UTF8Encoding utf8A = new UTF8Encoding();
        Encoding utf8B = Encoding.get_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());
    } //main
} //UTF8EncodingExample

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

UTF8Encoding-Klasse
UTF8Encoding-Member
System.Text-Namespace
Object.GetHashCode