Why am I getting a FormatException was unhandled error?

后端 未结 3 812
情话喂你
情话喂你 2020-12-12 01:51

I have created a program, and a extensive test of it, I\'m getting a error that says \"FormatException was unhandled, Input string was not in a correct format\". The problem

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 02:47

    You could use int.TryParse, which returns a bool to indicate whether the text was parsed successfully:

    int minsEntered = 0;
    if (int.TryParse(txtMins.Text, out minsEntered))
    {
        // txtMins.Text is a valid integer.
    }
    

提交回复
热议问题