Auf Englisch lesen

Freigeben über


Uri.GetHashCode Methode

Definition

Ruft den Hashcode für den URI ab.

C#
public override int GetHashCode ();

Gibt zurück

Der für diesen URI generierte Hashwert.

Beispiele

Im folgenden Beispiel wird eine Uri -Instanz erstellt und der Hashcode in die Konsole geschrieben.

C#
// Create Uri
Uri uriAddress = new Uri("http://www.contoso.com/index.htm#search");
Console.WriteLine(uriAddress.Fragment);
Console.WriteLine("Uri {0} the default port ", uriAddress.IsDefaultPort ? "uses" : "does not use");

Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path));
Console.WriteLine("Hash code {0}", uriAddress.GetHashCode());
// The example displays output similar to the following:
//        #search
//        Uri uses the default port
//        The path of this Uri is http://www.contoso.com/index.htm
//        Hash code -988419291

Gilt für: