How do I display a decimal value to 2 decimal places?

前端 未结 17 2580
没有蜡笔的小新
没有蜡笔的小新 2020-11-21 23:24

When displaying the value of a decimal currently with .ToString(), it\'s accurate to like 15 decimal places, and since I\'m using it to represent dollars and ce

17条回答
  •  生来不讨喜
    2020-11-22 00:01

    Double Amount = 0;
    string amount;
    amount=string.Format("{0:F2}", Decimal.Parse(Amount.ToString()));
    

提交回复
热议问题