HOWTO: Convert a string in scientific format to a decimal

K

Krish

Hi,

How to convert "1283912839E-5" string (in scientific format) to a decimal.

Convert.ToDecimal("1283912839E-5") is throwing "Input string is not in
correct format" exception. Is the exponential format not supported during
conversion?

I think we need to use NumberFormatInfo, but dont know how to use the format
specifiers in the NumberFormatInfo.

Thanks in advance.
 
C

Chris R

string x = "1283912839E-5";
decimal dec = Decimal.Parse( x, NumberStyles.AllowExponent );

Chris R.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top