| string latitude = reader.GetAttribute("lat"); string longitude = reader.GetAttribute("lon"); double lat = Convert.ToDouble(latitude); double lon = Convert.ToDouble(longitude); |
When latitude has a value of: 51.66777, lat has a value of 51667777... The same problem for longitude. When I convert the string, the point disappear. Can someone help me?
Thanks!
Hiren SoniPosted Jan 4, 2010, 5:35 AM
Santhosh NPosted Jan 4, 2010, 4:56 AM
Sven NijsPosted Jan 4, 2010, 4:05 AM
String latitude = reader.GetAttribute("lat");
String longitude = reader.GetAttribute("lon");
Double lat = System.Convert.ToDouble(latitude);
Double lon = System.Convert.ToDouble(longitude);
HtmlPage.Window.Alert("Lat: " + lat + ", Lon: " + lon);
Santhosh NPosted Jan 4, 2010, 4:02 AM
check if you are getting . or , carefullly and check
if you are getting other characters and wanted to convert thenm to . you can use this
string latitude = reader.GetAttribute("lat");
string longitude = reader.GetAttribute("lon");
double lat = Convert.ToDouble(latitude.Replace(',','.'); //Replaces all , with .
double lon = Convert.ToDouble(longitude.Replace(',','.');
Sven NijsPosted Jan 4, 2010, 3:59 AM
String latitude = reader.GetAttribute("lat");
String longitude = reader.GetAttribute("lon");
Double lat = System.Convert.ToDouble(latitude);
Double lon = System.Convert.ToDouble(longitude);
But the point of the string value still disappear after conversion to double...
Lalit MPosted Jan 4, 2010, 3:57 AM
string input = "5";
int i = Int32.Parse(input);
double d = Double.Parse(input);
char c = Char.Parse(input);
bool b = Boolean.Parse(input);
for reference
Rekha SinghPosted Jan 4, 2010, 3:57 AM
string latitude = "51.66777";
double lat = Convert.ToDouble(latitude);
Label1.Text = lat.ToString();
output : 51.66777
*****************************************
Please mark it Accepted if u find it helpful.
Lalit MPosted Jan 4, 2010, 3:52 AM