C# | Uri.GetHashCode() Method Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Uri.GetHashCode() Method is used to get the hash code for the URI. Syntax: public override int GetHashCode (); Return Value: This method returns an Int32 containing the hash value generated for this URI. Below programs illustrate the use of Uri.GetHashCode() Method: Example 1: csharp // C# program to demonstrate the // Uri.GetHashCode() Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing address1 string address1 = "https://www.microsoft.com/en-us/#search"; // Getting HashCode by // using GetHashCode() method int value = address1.GetHashCode(); // Displaying the result Console.WriteLine("HashCode is : {0}", value); } } Output: HashCode is : 2065713268 Example 2: csharp // C# program to demonstrate the // Uri.GetHashCode() Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // calling get() method get(new Uri("http://www.contoso.com")); get(new Uri("http://www.google.com")); } // defining get() method public static void get(Uri address1) { // Getting HashCode by // using GetHashCode() method int value = address1.GetHashCode(); // Displaying the result Console.WriteLine("HashCode is : {0}", value); } } Output: HashCode is : 2014 HashCode is : 1498 Reference: https://learn.microsoft.com/en-us/dotnet/api/system.uri.gethashcode?view=netstandard-2.1 Comment More infoAdvertise with us Next Article C# | Type.GetHashCode() Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Uri-Class Similar Reads C# | Type.GetHashCode() Method Type.GetHashCode() Method is used to return the hash code for this instance. Syntax: public override int GetHashCode (); Return Value: This method returns the hash code for the current instance. Below programs illustrate the use of Type.GetHashCode() Method: Example 1: csharp // C# program to demons 2 min read C# | Type.GetHashCode() Method Type.GetHashCode() Method is used to return the hash code for this instance. Syntax: public override int GetHashCode (); Return Value: This method returns the hash code for the current instance. Below programs illustrate the use of Type.GetHashCode() Method: Example 1: csharp // C# program to demons 2 min read C# | Byte.GetHashCode() Method This method is used to return the hash code for the given byte.Syntax: public override int GetHashCode (); Return Value: This method returns a hash code for the current Byte.Below programs illustrate the use of Byte.GetHashCode() Method:Example 1: CSHARP // C# program to demonstrate // Byte.GetHashC 2 min read C# | Byte.GetHashCode() Method This method is used to return the hash code for the given byte.Syntax: public override int GetHashCode (); Return Value: This method returns a hash code for the current Byte.Below programs illustrate the use of Byte.GetHashCode() Method:Example 1: CSHARP // C# program to demonstrate // Byte.GetHashC 2 min read Double.GetHashCode() Method in C# Double.GetHashCode() Method is used to return the hash code for this instance. Syntax: public override int GetHashCode (); Return Value: This method returns a 32-bit signed integer hash code. Below programs illustrate the use of Double.GetHashCode() Method: Example 1: csharp // C# program to demonst 1 min read Double.GetHashCode() Method in C# Double.GetHashCode() Method is used to return the hash code for this instance. Syntax: public override int GetHashCode (); Return Value: This method returns a 32-bit signed integer hash code. Below programs illustrate the use of Double.GetHashCode() Method: Example 1: csharp // C# program to demonst 1 min read Like