When you say
on my system floating point numbers are stored with a comma as the decimal separator
I assume you mean that they are formatted with a comma, floating point numbers are stored as float
.
Whilst you can tackle the formatting issue by setting Cultures the "real" fix is to change the code. OK, it's not your code so maybe you don't want to do that on this occassion, but for general reference you need to ensure that when formatting floats or anything else you use the appropriate culture. In the case of fomatting a number for use by an API you would use the InvariantCulture.
I.e. use foo.ToString(CultureInfo.InvariantCulture)
instead of foo.ToString()
and likewise when using string.Format(...).
Edit I've just taken a look at the NerdDinner code and have realised that this error is in the Javascript not in C#, so my code above isn't going to help. I don't know if it is possible to format numbers in Javascript, but the real solution I think is to fix the model code to return a correctly formatted string.
Edit 2 I'd suggest you try the following:
In the SearchController.cs
change the Latitude
and Longitude
in JsonDinner
to strings
. i.e.
public class JsonDinner {
public int DinnerID { get; set; }
public string Title { get; set; }
public string Latitude { get; set; }
public string Longitude { get; set; }
public string Description { get; set; }
public int RSVPCount { get; set; }
}
Then scroll down to the SearchByLocation method and change the Lat/Long lines to format the strings correctly for JavaScript:
Latitude = dinner.Latitude.ToString(CultureInfo.InvariantCulture),
Longitude = dinner.Longitude.ToString(CultureInfo.InvariantCulture),
This should mean that you do not need the fix you put in, and should fix your other question... where I will leave a comment. Hope this helps, I haven't fully tested is as I am not in your locale, but it certainly appears to work.