i have a string array with different latitudes and longitudes,i want to read only the digits and store it into a new string.
private static void Main(string[] args)
{
string[] str_array = new string[2];
str_array[0] = "lat = 30.25588 ; lon = 75.22558;";
str_array[1] = "lat = 30.23088 ; lon = 46.22558;";
str_array[2] = "lat = 30.24688 ; lon = 75.22758;";
string result = "";
string checkstring = ".0123456789";
for (int i = 0; i <= str_array.Length; i++)
{
for (int j = 0; j <= str_array[i].Length; j++)
{
if (checkstring.Contains(str_array[i][j]))
{
result += str_array[i][j].ToString();
}
else if (str_array[i][j] == ';')
{
result += " ";
}
}
}
Console.WriteLine(result);
Console.ReadLine();