在C#中获取当前UInt64实例的HashCode
要获取当前UInt64实例的HashCode,代码如下-
示例
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()); } }
输出结果
这将产生以下输出-
HashCode for val1 = 8768768 HashCode for val2 = 0
示例
让我们看另一个例子-
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()); } }
输出结果
这将产生以下输出-
HashCode for val1 = 89879878 HashCode for val2 = 0