title: GeoCoordinate in C#
body: <p><code>f_lat</code> should return with value of customer latitude,but there is a mistake somewhere so it returns 1(return 1 is not expected result).</p>
  
  <p>The coordinates of customer and drivers returns correctly from database.</p>
  
  <p>When I put <code>return f_lat;</code> before <code>GeoCoordinate</code> constructor,it returns correct latitude of customer,but I put after <code>GeoCoordinate</code> constructor,it returns wrong latitude of customer.</p>
  
  <p>Who can help to me?</p>
  
  <pre><code>[WebMethod]
  public double FindNearestTaxiDriver(string f_mobilephone)
  {
  
  
      double f_lat = 0.0;
      double f_lng = 0.0;
  
      ArrayList d_mobilephone = new ArrayList();
      ArrayList d_lat = new ArrayList();
      ArrayList d_lng = new ArrayList();
  
      ArrayList distanceBetweenTwoPoints = new ArrayList();
  
      MySqlConnection mySqlConnection = new MySqlConnection(ConfigurationManager.ConnectionStrings["connect"].ToString());
      MySqlCommand f_mySqlCommand = new MySqlCommand("Select f_lat,f_lng from farecoordinates where f_mobilephone='" + f_mobilephone + "'",mySqlConnection);
      MySqlCommand d_mySqlCommand = new MySqlCommand("Select d_mobilephone,d_lat,d_lng from drivercoordinates", mySqlConnection);
  
      try
      {
          mySqlConnection.Open();
          MySqlDataReader mySqlDataReader = f_mySqlCommand.ExecuteReader();
          while (mySqlDataReader.Read())
          {
              f_lat = Convert.ToDouble(mySqlDataReader["f_lat"].ToString());
              f_lng = Convert.ToDouble(mySqlDataReader["f_lng"].ToString());
          }
  
          mySqlDataReader.Dispose();
  
          mySqlDataReader = d_mySqlCommand.ExecuteReader();
  
          while (mySqlDataReader.Read())
          {
              d_mobilephone.Add(mySqlDataReader["d_mobilephone"].ToString());
              d_lat.Add(Convert.ToDouble(mySqlDataReader["d_lat"].ToString()));
              d_lng.Add(Convert.ToDouble(mySqlDataReader["d_lng"].ToString()));
          }
          GeoCoordinate f_coordinates = new GeoCoordinate(f_lat, f_lng);
          GeoCoordinate d_coordinates = new GeoCoordinate();
  
          for (int i = 0; i &lt; d_mobilephone.Count; i++)
          {
              d_coordinates.Latitude = Convert.ToDouble(d_lat[i]);
              d_coordinates.Longitude = Convert.ToDouble(d_lng[i]);
  
              distanceBetweenTwoPoints.Add(f_coordinates.GetDistanceTo(d_coordinates));
          }
          //distanceBetweenTwoPoints.Sort();
          return f_lat;
  
      }
      catch (Exception)
      {
  
          return 1.0;
      }
      finally
      {
          f_mySqlCommand.Dispose();
          mySqlConnection.Dispose();
          mySqlConnection.Close();
      }
  }
  </code></pre>