要获取当前Decimal实例的哈希码,代码如下-
using System; public class Demo { public static void Main(){ Decimal val = 135269.38193M; Console.WriteLine("Decimal Value = {0}", val); Console.WriteLine("HashCode = {0}", (val.GetHashCode()) ); } }
输出结果
这将产生以下输出-
Decimal Value = 135269.38193 HashCode = 1328665595
现在让我们来看另一个示例-
using System; public class Demo { public static void Main(){ Decimal val = Decimal.MaxValue; Console.WriteLine("Decimal Value = {0}", val); Console.WriteLine("HashCode = {0}", (val.GetHashCode()) ); } }
输出结果
这将产生以下输出-
Decimal Value = 79228162514264337593543950335 HashCode = 1173356544