在 C# 中获取当前 Decimal 实例的哈希码
csharpserver side programmingprogramming更新于 2025/5/20 10:52:17
要获取当前 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

