469,117 Members | 1,370 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,117 developers. It's quick & easy.

Convert.ToDouble ?

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

Nov 16 '05 #1
3 4492
us**@domain.invalid wrote:
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.

Nov 16 '05 #2
Hi Michal,

<us**@domain.invalid> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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
Nov 16 '05 #3
Hi,

<us**@domain.invalid> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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 '.'?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by cindy liu | last post: by
4 posts views Thread by Irepan | last post: by
10 posts views Thread by | last post: by
3 posts views Thread by user | last post: by
2 posts views Thread by Jason | last post: by
4 posts views Thread by Edwin Knoppert | last post: by
3 posts views Thread by mrajanikrishna | last post: by
2 posts views Thread by trondhuso | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.