Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# - Show a decimal to 6 decimal places [duplicate]

Tags:

c#

Possible Duplicate:
Double.ToString with N Number of Decimal Places

I want to show a decimal to 6 decimal places, even if it contains 6 x 0's For example:

3.000000
5.100000
3.456789

and so forth, is this possible?

like image 348
CallumVass Avatar asked Dec 07 '11 09:12

CallumVass


2 Answers

Use N6 as the numeric format string.

myDecimal.ToString("N6");

or

string.Format("{0:N6}", myDecimal);
like image 86
Joey Avatar answered Oct 12 '22 06:10

Joey


Decimal d = 20;
d.ToString("0.000000");
like image 22
Russell Troywest Avatar answered Oct 12 '22 08:10

Russell Troywest