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

前端 未结 17 2171
没有蜡笔的小新
没有蜡笔的小新 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-21 23:59

    If you want it formatted with commas as well as a decimal point (but no currency symbol), such as 3,456,789.12...

    decimalVar.ToString("n2");
    

提交回复
热议问题