Convert.ToDouble ?

  • Thread starter Thread starter user
  • Start date Start date
U

user

Hello
i have problems with this function, always thru exception
for all data, for example: Convert.ToDouble("545.0"). Why ?

I want to convert string data in different format into double,
i have formats like:
37.439351
2.00000e+02

How can i do it most easily ?

Thanx
Michal
 
Hello
i have problems with this function, always thru exception
for all data, for example: Convert.ToDouble("545.0"). Why ?

I want to convert string data in different format into double,
i have formats like:
37.439351
2.00000e+02

How can i do it most easily ?

What exception are you getting? The above should work fine so we need
details around the exception and what else is going on.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.
 
Hi Michal,

Hello
i have problems with this function, always thru exception
for all data, for example: Convert.ToDouble("545.0"). Why ?

I want to convert string data in different format into double,
i have formats like:
37.439351
2.00000e+02

How can i do it most easily ?

Thanx
Michal

The only reason I can figure that the above code would cause an
exception is if the number is not in a valid format for your current
culture. If you specify the invariant culture does it still cause an
exception?:

double val = Convert.ToDouble("545.0", CultureInfo.InvariantCulture);

CultureInfo is in the System.Globalization namespace.

Regards,
Daniel
 
Hi,

Hello
i have problems with this function, always thru exception
for all data, for example: Convert.ToDouble("545.0"). Why ?

Is it possible that your decimal separator is not '.'?
 
Back
Top