I have string which is like this:
string line = "77.139305\t28.795975"
and i seperate the two integers like this:
string lat = line.Substring(0, 9);
string lng = line.Substring(10, 9);
whic exactly seperates the 2 numbers like this:
"77.139305" and "28.795975" for lat and lng.
int latitude,longitude;
bool result = Int32.TryParse(lat, out latitude);
if (result)
{
col1[i] = latitude;
Console.WriteLine("lat: " + col1[i]);
}
else
{
if (lat == null) lat = "";
Console.WriteLine("Attempted conversion of lat '{0}' failed.", lat);
}
bool result2 = Int32.TryParse(lng, out longitude);
if (result2)
{
col2[i] = longitude;
Console.WriteLine("longit: " + col2[i]);
}
else
{
if (lng == null) lng = "";
Console.WriteLine("Attempted conversion of lng '{0}' failed.", lng);
}
As a result it always excutes else condition and if i don't handle this exception in else condition then it gives "input string was not in a correct format in c# net int.parse" How to solve this problem ?