Reputation: 177
I have a problem. I have a double number like 0.00000001. Then I should convert it into String and put it in textbox (Convert.ToString(0.00000001)). But that number displayed like 1E-08. Math.Round is not working here. I should display that number like 0.00000 (at least), not just 0.
Upvotes: 3
Views: 183
Reputation: 98810
You can use The numeric ("N")
format specifier for that;
(0.00000001).ToString("N5").Dump(); // 0,00000
(0.00000001).ToString("N6").Dump(); // 0,000000
(0.00000001).ToString("N8").Dump(); // 0,00000001
Since my CurrentCulture
's NumberDecimalSeparator
is ,
, it represents it as 0,0
not 0.0
. If it is the same for you, you can use InvariantCulture
as a second parameter in your .ToString()
method.
Upvotes: 5