[ACCEPTED]-Representing Numbers in Exponential form-c#

Accepted answer
Score: 11

You'll need to use a custom format string 4 to specify how to format your decimal:

string.Format("{0:0.##E+00}", dValue);

You 3 can find more about custom numeric format 2 strings on the MSDN here. There's a specific 1 section on Exponent formats.

Score: 6

I think you want something like:

string text = dValue.ToString("0.###E+00");

(Change the number 6 of # characters to change the number of decimal 5 digits before the E.)

You can do this with a compound 4 format specifier as well by calling string.Format, but 3 personally I'd use a simple one unless you 2 need to put other text round it anyway, in 1 which case you'd use use something like:

string text = string.Format("Before {0:0.0###E+00} After", dValue);

More Related questions