在 C# 中获取当前 UInt32 实例的哈希码
要获取当前 UInt32 实例的哈希码,代码如下 -
示例
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()); } }
输出
这将产生以下输出 -
HashCode for val1 = 100 HashCode for val2 = 0
示例
我们来看另一个示例 -
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()); } }
输出
这将产生以下输出 -
HashCode for val1 = 50 HashCode for val2 = 65535
广告