How to round System.Decimal in .Net to a number of significant figures

后端 未结 4 553
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 15:00

I have a System.Decimal number

0.00123456789

and I wish to round to 3 significant figures. I expect

0.00123

with the behaviour to be a roundi

4条回答
  •  一向
    一向 (楼主)
    2021-01-19 15:34

    in example:

    decimal a = 1.9999M;
    decimal b = Math.Round(a, 2); //returns 2
    

提交回复
热议问题