I am having double value = 30308950000;
I want to display it like 3.03x10^10
How can I achieve it using C#?
I have tried
double value = 30308950000;
Console.WriteLine(value.ToString("0.###E+0", CultureInfo.InvariantCulture));
output = 3.03E+10
I dont want the 3.03E+10
format but 3.03x10^10
.
Thanks
Easy fix:
Shout out to Jon Skeet! :)
Sadly, NumberFormarInfo doesn't provide any ExponentialSign parameter.
That it, the Exponential Format Specifier (E) use only NegativeSign, NumberDecimalSeparator and PositiveSign information from the NumberFormarInfo.
To do it "in the pattern", you have to use your own implementation of ICustomFormatter like here.