Reputation: 3
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 know how to show a double number in a label?
Upvotes: 0
Views: 10307
Reputation: 3582
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"
Upvotes: 0
Reputation: 74370
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.
Upvotes: 1
Reputation: 101604
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.
Upvotes: 2