Sign in to follow this  
vegi

String Convert fails [c#]

Recommended Posts

Hi, i want to read numbers from strings. The Input String is "3399084.171875".I tryed to convert it with Convert.ToDouble but the result is "3399084171875.0". Any idea why ? Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by vegi
Hi,

i want to read numbers from strings. The Input String is "3399084.171875".I tryed to convert it with Convert.ToDouble but the result is "3399084171875.0".

Any idea why ?

Thanks.


In your country format is "." the decimal separator? because if you call Convert.ToDouble without a specific culture it use the default one of your country. (Probably in your country the "," is the decimal separator)

Share this post


Link to post
Share on other sites
A better option might just be to use the correct culture when doing the string conversion. Of course, that is only if you care about localization.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this