When i try it like you say, he ignores the dot.
>
For example
>
s = "12.45";
d = double.Parse(s) ;
>
d will be 1245.0 :(
What are your culture settings? Clearly, parsing "12.45" as a double
would normally work in the context of a US-configured computer. I will
hazard a guess that you're using the comma for the decimal separator, and
the period for the thousands separator. If that's the case, then you need
to parse "12,45" if you expect to have a value returned that is twelve and
forty-five hundredths.
There are overloads for the Parse() method that take culture-specific
format providers, so if you know the string is from a specific culture
that may be different from what the user has configured, you can use those
to ensure correct conversion.
<Nicolai.Schoen berg@googlemail .comwrote in message
news:1183711693 .670856.221550@ m36g2000hse.goo glegroups.com.. .
When i try it like you say, he ignores the dot.
>
For example
>
s = "12.45";
d = double.Parse(s) ;
>
d will be 1245.0 :(
This is because the default Culture that you are using defines de dot as
a thousands separator instead of a decimal point. You can either write your
string with a comma for the decimal point ("12,45"), or change the
CurrentCulture, or change the FormatProvider of the Parse method:
using System.Globaliz ation;
....
CultureInfo ci = new CultureInfo("en-US");
....
s = "12.45";
d = double.Parse(s, ci);
Comment