UInt32.GetHashCode() 方法在 C# 中的示例
C# 中的 UInt32.GetHashCode() 方法用于获得当前 UInt32 实例的 HashCode。
语法
语法如下所示 −
public override int GetHashCode ();
示例
让我们看一个实现 UInt32.GetHashCode() 方法的示例 −
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
示例
现在,我们来看另一个实现 UInt32.GetHashCode() 方法的示例 −
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
广告