Input string was not in a correct format #2

后端 未结 10 1267
一向
一向 2020-12-03 21:24
double temp;
temp = (double)Convert.ToDouble(\"1234.5678\");

Hey Lads and Ladies, I can\'t for the life of me figure out why the above line isn\'t

10条回答
  •  萌比男神i
    2020-12-03 21:54

    As far as I know the Convert methods use the current locale to do such conversions. In this case I'd guess your current locale would expect a comma as decimal point. Try to set the current locale for your application or the conversion to some language/country where dots are used (e.g. en_US). The method should provide a second optional parameter to provide a IFormatProvider as an alternative solution.

提交回复
热议问题