How to display a number close to zero in C #?
I have a problem. I have a double number like 0.00000001. Then I have to convert it to String and put it in the textbox (Convert.ToString (0.00000001)). But this number is displayed as 1E-08. Math.Round doesn't work here. I have to show this number, for example 0.00000 (at least), not just 0.
source to share
You can use a numeric format specifier("N")
for this;
(0.00000001).ToString("N5").Dump(); // 0,00000
(0.00000001).ToString("N6").Dump(); // 0,000000
(0.00000001).ToString("N8").Dump(); // 0,00000001
Since mine is , it represents it as not . If it's the same for you, you can use it as the second parameter in your method .CurrentCulture
NumberDecimalSeparator
,
0,0
0.0
InvariantCulture
.ToString()
source to share