Double.Parse - Internationalization problem
- by oz
This is driving me crazy. I have the following string in a ASP.NET 2.0 WebForm Page
string s = "0.009";
Simple enough. Now, if my culture is Spanish - which is "es-ES" - and I try to convert the string to Double, I do the following:
double d = Double.Parse(s, new CultureInfo("es-ES"));
what I'd expect is 0,009. Instead, I get 9. I understand that .NET thinks it is a thousand separator, which in en-US is a comma, but shouldn't it take the culture info I'm passing to the parse method and apply the correct format to the conversion?
If I do
double d = 0.009D;
string formatted = d.ToString(new CultureInfo("es-ES"));
formatted is now 0,009. Anybody?