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

前端 未结 17 2178
没有蜡笔的小新
没有蜡笔的小新 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:03

    decimalVar.ToString ("#.##"); // returns "" when decimalVar == 0
    

    or

    decimalVar.ToString ("0.##"); // returns "0"  when decimalVar == 0
    

提交回复
热议问题