Very weird problem with Convert.Double in ASP.NET
I have a very simple code that works on my PC:
String latitude = "2.3444";
String longitude = "34.333";
Double lat = Convert.ToDouble(latitude);
Double lng = Convert.ToDouble(longitude);
In my pc "." is decimal separator.
I uploaded to server. It fails. I looked at Regional Settings, it was "," as decimal separator. I changed it to ".". I stopped my web app and resta开发者_如何转开发rted it but it still fails. Why ?
Try adding CultureInfo.InvariantCulture.
using System.Globalization
String latitude = "2.3444";
String longitude = "34.333";
Double lat = Convert.ToDouble(latitude, CultureInfo.InvariantCulture);
Double lng = Convert.ToDouble(longitude, CultureInfo.InvariantCulture);
精彩评论