Input string was not in a correct format

后端 未结 8 1299
滥情空心
滥情空心 2020-11-22 02:55

I\'m new with C#, I have some basic knowledge in Java but I can\'t get this code to run properly.

It\'s just a basic calculator, but when I run the program VS2008 gi

8条回答
  •  無奈伤痛
    2020-11-22 03:14

    If you are not validating explicitly for numbers in the text field, in any case its better to use

    int result=0;
    if(int.TryParse(textBox1.Text,out result))
    

    Now if the result is success then you can proceed with your calculations.

提交回复
热议问题