UInt64.GetHashCode() 方法 (带示例)
C# 中的 UInt64.GetHashCode() 方法用于获取当前 UInt64 实例的哈希码。
语法
以下是语法 −
public override int GetHashCode ();
示例
现在让我们看一个示例来实现 UInt64.GetHashCode() 方法 −
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
示例
现在让我们看另一个示例来实现 UInt32.GetHashCode() 方法 −
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
广告