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
  • 91,784
  • 22
  • 134
  • 156
udaya726
  • 1,010
  • 6
  • 21
  • 41

1 Answers1

7

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,421,763
  • 867
  • 9,128
  • 9,194