ToDouble() - problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This should be simple, but either I'm blind, stupid or going mad.

I'm trying to convert a string, containing a numeric value to a double (in
C#), but when I run the code below I get the error message "Input string was
not in a correct format." Why?

string s = "8.0";
double d = Convert.ToDouble(s);
 
Hi,

No reason to fail. Check your decimal symbol entry on the regional
settings/control panel. But it should parse it in anyway.
Finally you can try to use a formatprovider to assign the dot as a decimal
seperator.

Good Luck
Adnan

This should be simple, but either I'm blind, stupid or going mad.

I'm trying to convert a string, containing a numeric value to a double (in
C#), but when I run the code below I get the error message "Input string
was
not in a correct format." Why?

string s = "8.0";
double d = Convert.ToDouble(s);
 
henfo said:
This should be simple, but either I'm blind, stupid or going mad.

I'm trying to convert a string, containing a numeric value to a double (in
C#), but when I run the code below I get the error message "Input string was
not in a correct format." Why?

string s = "8.0";
double d = Convert.ToDouble(s);

Please see my response in one of the other newsgroups you posted to.
It's generally not a good idea to post to multiple newsgroups,
precisely for this reason. See
http://www.pobox.com/~skeet/csharp/faq/posting.html for more
explanations.
 

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

Back
Top