Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert.ToDouble("1.3") returns 13 [duplicate]

What's going on here?

Convert.ToDouble("1.3")

I have a string with the value "1.3". When I convert to double, it returns 13. I want to return 1.3.

like image 745
alansiqueira27 Avatar asked Dec 20 '22 15:12

alansiqueira27


1 Answers

It probably has to do with your current culture, it uses another decimal separator symbol than .. You can do this instead:

double.Parse("1.3", CultureInfo.InvariantCulture);
like image 71
Magnus Avatar answered Jan 11 '23 23:01

Magnus