在 C# 中获取值类型 Decimal 的 TypeCode
要获得值类型 Decimal 的 TypeCode,代码如下 −
示例
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()) ); TypeCode type = val.GetTypeCode(); Console.WriteLine("TypeCode = "+type); } }
输出
这将产生以下输出 −
Decimal Value = 79228162514264337593543950335 HashCode = 1173356544 TypeCode = Decimal
示例
现在让我们看另一个例子 −
using System; public class Demo { public static void Main(){ Decimal val = 3972.491M; Console.WriteLine("Decimal Value = {0}", val); Console.WriteLine("HashCode = {0}", (val.GetHashCode()) ); TypeCode type = val.GetTypeCode(); Console.WriteLine("TypeCode = "+type); } }
输出
这将产生以下输出 −
Decimal Value = 3972.491 HashCode = 620041307 TypeCode = Decimal
广告