tags:

views:

18

answers:

1

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 restarted it but it still fails. Why ?

+2  A: 

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);
Ole Melhus
Thanks it works :) though I still don't understand why since decimal separator is the same.