I searched a lot about this problem but the only results I get is with numbers like 5.04 My number is >1 so for example 0.8 number.ToString("F2") is the way I tried but haven't found a format yet that worked. So Do anybody kno开发者_运维问答w how to show a double number in a label?
The article on MSDN may be of help regarding formatting a Decimal number in a variety of formats. Scroll a bit down and view the examples given and their output they would provide.
Not sure what you are asking, but what's wrong with:
string formatted = string.Format("{0:F2}",0.8);
It produces 0.80, which I thought is what you were looking for.
Have you tried:
string s = String.Format("{0:0.00}", 0.8);
Formatted two decimal places:
String.Format("{0:0.00}", 123.4567); // "123.46"
String.Format("{0:0.00}", 123.4); // "123.40"
String.Format("{0:0.00}", 123.0); // "123.00"
精彩评论