Uri.GetHashCode Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the hash code for the URI.

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


Public Overrides Function GetHashCode As Integer
public override int GetHashCode()

Return Value

Type: System.Int32
An Int32 containing the hash value generated for this URI.


The following example creates a Uri instance and writes the hash code to the console.

' Create Uri
Dim uriAddress1 As Uri = New Uri("http://www.contoso.com/index.htm#search")
outputBlock.Text &= uriAddress1.Fragment
outputBlock.Text &= vbCrLf

outputBlock.Text &= "Hash code: "
outputBlock.Text &= uriAddress1.GetHashCode()
outputBlock.Text &= vbCrLf
// Create Uri
Uri uriAddress1 = new Uri("http://www.contoso.com/index.htm#search");
outputBlock.Text += uriAddress1.Fragment;
outputBlock.Text += "\n";

outputBlock.Text += "Hash code: ";
outputBlock.Text += uriAddress1.GetHashCode();
outputBlock.Text += "\n";
// Create Uri
Uri uriAddress = new Uri("http://www.contoso.com/index.htm#search");

Console.WriteLine("Hash code {0}", uriAddress.GetHashCode());

Version Information


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0


For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also