C# Double - ToString() formatting with two decimal places but no rounding

问题:

How do I format a Double to a String in C# so as to have only two decimal places?如何在 C# 中将Double格式化为String以便只有两位小数?

If I use String.Format("{0:0.00}%", myDoubleValue) the number is then rounded and I want a simple truncate without any rounding.如果我使用String.Format("{0:0.00}%", myDoubleValue)然后对数字进行四舍五入,我想要一个没有任何四舍五入的简单截断。 I also want the conversion to String to be culture sensitive.我还希望转换为String是文化敏感的。


解决方案:

参考一: https://en.stackoom.com/question/AINr
参考二: https://stackoom.com/question/AINr
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章