| 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!

Lalit MRank #1,186 · 1.5K reputationPosted Jan 3, 2010, 10:52 PM EST
Use this code sample String salary = "5555"; // Sample 1 Double mySalary = Double.Parse(salary); // Sample 2 mySalary = System.Convert.ToDouble(salary);Rekha SinghRank #1,571 · 1K reputationPosted Jan 3, 2010, 10:57 PM EST
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 MRank #1,186 · 1.5K reputationPosted Jan 3, 2010, 10:57 PM EST
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
Sven Nijs14 reputationPosted Jan 3, 2010, 10:59 PM EST
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...
Santhosh NRank #4,788 · 325 reputationPosted Jan 3, 2010, 11:02 PM EST
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 Nijs14 reputationPosted Jan 3, 2010, 11:05 PM EST
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 NRank #4,788 · 325 reputationPosted Jan 3, 2010, 11:56 PM EST
Hiren SoniRank #694 · 3.5K reputationPosted Jan 4, 2010, 12:35 AM EST