如何从decimal.GetBits()的结果中返回十进制值

时间:2012-09-26 07:12:28

标签: c# .net

  

可能重复:
  How to convert System.Decimal bits to string in C#?

我从decimal.GetBits()得到int []。如何从int []中获取十进制值?

3 个答案:

答案 0 :(得分:3)

使用Decimal(Int32[] bits)构造函数。像这样:

Decimal d = new Decimal( 123 );
Int32[] bits = d.GetBits();
Decimal e = new Decimal( bits );
Debug.Assert( d == e );

答案 1 :(得分:1)

它可以像这样转换回来:

var decimal = new Decimal(decimalBitArray)

请参阅MSDN Decimal

答案 2 :(得分:1)

decimal dec = new decimal(decimalArray);