UInt32.GetHashCode() Method in C# with Examples

CsharpServer Side ProgrammingProgramming

The UInt32.GetHashCode() method in C# is used to get the HashCode for the current UInt32 instance.

Syntax

Following is the syntax −

public override int GetHashCode ();

Example

Let us now see an example to implement the UInt32.GetHashCode() method −

using System;
public class Demo {
   public static void Main(){
      uint val1 = 100;
      uint val2 = UInt16.MinValue;
      Console.WriteLine("HashCode for val1 = "+val1.GetHashCode());
      Console.WriteLine("HashCode for val2 = "+val2.GetHashCode());
   }
}

Output

This will produce the following output −

HashCode for val1 = 100
HashCode for val2 = 0

Example

Let us now see another example to implement the UInt32.GetHashCode() method −

using System;
public class Demo {
   public static void Main(){
      uint val1 = 50;
      uint val2 = UInt16.MaxValue;
      Console.WriteLine("HashCode for val1 = "+val1.GetHashCode());
      Console.WriteLine("HashCode for val2 = "+val2.GetHashCode());
   }
}

Output

This will produce the following output −

HashCode for val1 = 50
HashCode for val2 = 65535
raja
Published on 14-Nov-2019 06:54:58
Advertisements