URI stands for uniform resource identifier. It is used to represent a resource on the internet. This resource could be a code snippet, an image, API, and so on.
We can get the hash of a URI object by using the GetHashCode()
method. It returns an integer value that represents the hash of the object. A hash or hashcode is a unique value that an object has.
Uri.GetHashCode()
This method does not take any parameters.
The value returned is an integer that is the hash value generated for the particular URI object.
using System;class HelloWorld{static void Main(){// Create some Uri objectsUri uri1 = new Uri("https://www.educative.io/");Uri uri2 = new Uri("https://www.educative.io/");Uri uri3 = new Uri("https://www.educative.io/index.html");Uri uri4 = new Uri("https://www.educative.io/edpresso");// check if they are not equalConsole.WriteLine(uri1.GetHashCode());Console.WriteLine(uri2.GetHashCode());Console.WriteLine(uri3.GetHashCode());Console.WriteLine(uri4.GetHashCode());}}