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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章