Why does double.Parse ("0.05") return 5.0?
I am reading the value from my App.config; which the:
<add key="someValue" value="0.05"/>
And I'm trying to convert it to double by doing:
var d = double.Parse(ConfigurationManager.AppSettings["someValue"]);
And I get 5.0 instead of 0.05.
Can you advise? What am I doing wrong and how should I disassemble it?
This is for your culture settings, check the same thing, but specify a period instead of a comma, and you will see that
var d = double.Parse("0,05");
To fix this problem, you could use the following parsing function overload
var d = double.Parse(ConfigurationManager.AppSettings["someValue"], CultureInfo.InvariantCulture);