4

I have a null able double value which get values from data base.It retrieve value from data base as '1E-08'. I want to display the value with out scientific notification (0.00000001)

I used the following code.

double? valueFromDB=1E-08;
string doubleValue=valueFromDB.Value.Value.ToString();
string formatedString=String.Format("{0:N30}", doubleValue);

But the value of formatedString is still 1E-08.

Robby Cornelissen
  • 81,630
  • 19
  • 117
  • 142
udaya726
  • 980
  • 5
  • 19
  • 41

1 Answers1

6

You're calling string.Format with a string. That's not going to apply numeric formatting. Try removing the second line:

double? valueFromDB = 1E-08;
string formattedString = String.Format("{0:N30}", valueFromDB.Value);

Or alternatively, specify the format string in a call to ToString on the value:

double? valueFromDB = 1E-08;
string formattedString = valueFromDB.Value.ToString("N30");

That produces 0.000000010000000000000000000000 for me.

Jon Skeet
  • 1,335,956
  • 823
  • 8,931
  • 9,049