Get the HashCode for the current UInt64 instance in C#

CsharpServer Side ProgrammingProgramming

To get the HashCode for the current UInt64 instance, the code is as follows −

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      ulong val1 = 8768768;
      ulong val2 = UInt64.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 = 8768768
HashCode for val2 = 0

Example

Let us see another example −

 Live Demo

using System;
public class Demo {
   public static void Main() {
      ulong val1 = 89879878;
      ulong val2 = UInt64.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 = 89879878
HashCode for val2 = 0
raja
Published on 11-Dec-2019 07:37:09
Advertisements