How To Solve Unhandled Exception: System.FormatException: Input string was not in a correct format.

MonalishaMonalisha Member ✭✭

I am working on TextChanged event on Entry field. But It is showing Unhandled Exception: System.FormatException: Input string was not in a correct format.
occurred.
Anyone suggect me where i am wrong.

Best Answer

Answers

  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    @Monalisha Which line is raising this exception? Probably some of the text that you are trying to convert to int has got non-numeric characters.

  • NMackayNMackay GBInsider, University mod

    @Monalisha

    Check out the parse documentation and look up why your getting the exception

    https://stackoverflow.com/questions/9372210/int-parse-input-string-was-not-in-a-correct-format

    TryParse for example won't throw an exception and you can check the return value. Your code will crash your app by putting something non numeric into you entry unless you wrap that code in a try catch.

    Resharper may be an idea to help you clean up your variable naming as well.

Sign In or Register to comment.