locked
how to use Double.TryParse in smart device(mobile) in C# RRS feed

  • Question

  • Hello,
     I'm developing a application in Smart Dvice using C# in that i used  Double.TryParse it giving error is : 'double' does not contain a definition for 'TryParse'  pl send code for this
    My code is 
      private void MapCurrentLocBtn_Click(object sender, EventArgs e)
            {
                double lat, lon;
               if (internetConnected && Double.TryParse(currentLatitudeTbx.Text, out lat)
                                 && Double.TryParse(currentLongitudeTbx.Text, out lon))
             }
    Thursday, February 11, 2010 10:28 AM

Answers

  • It's not implemented in the compact framework. The documentation for the method only list it as being available in the full framework. But the omission is minor. You can make your own tryParse method.

    bool TryParseDouble(string source, out double result)
    {
         try (
              result = double.parse(source);
         ) catch(exception)
         { return false; }
         return true;
    }

    It takes all the running you can do to stay in one place.If you want to get somewhere else,you must try to run at least twice as fast as that.
    • Proposed as answer by ctacke Thursday, February 11, 2010 5:16 PM
    • Marked as answer by warrentang Monday, February 15, 2010 6:58 AM
    Thursday, February 11, 2010 1:50 PM