Saturday, March 28, 2015

Convert Scientific Notation String to Double in c#


I was working with conversion of some scientific notation numbers like this "2.09550901805872E-05" which was represented in string to double.
 
When I did that using regular ToConvert function , it was throwing an exception.
 
After few research, I found out that it should be done using Parse function and NumberStyles as shown below.
 
Double.Parse("<Scientific Exponent String>", NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint);
 
Hope this tip helps.
 
Cheers
Adam

All Blogs so far ...