I am parsing an xml file and I am trying to assign a value which I is read from xml file into a double variable.
here is what my code looks like:
double someDouble = Convert.ToDouble(someString);
problem here is, when executing this line of code, i get
An unhandled exception of type ‘System.FormatException’ occurred in
mscorlib.dllAdditional information: Input string was not in a correct format.
When I debug, i see that the value of someString is “45.00000000” in the “Locals” view.
As far as I know Convert.ToDouble supports such converting strings into double.
NOTE: just to be sure I also tried
double someDouble = Convert.ToDouble(someString.Trim('"'));
It works fine for me.
My psychic debugging skills tell me that you’re running in a culture that uses
,as the decimal separator.Pass
CultureInfo.InvariantCulture.