Error when trying to get an int from textbox

前端 未结 5 1139
时光取名叫无心
时光取名叫无心 2021-01-20 04:37

I am new to C# and programming in general. I was able to create the required program in Console but want to get one working with Forms as well. I am running into an issue wh

5条回答
  •  遇见更好的自我
    2021-01-20 05:13

    Remove those definitions from button1_Click() method as you use the same names as the class variables inside this method:

    int LengthtextBox;
    int WidthtextBox;
    int HeighttextBox;
    

    And change the name of the variables:

    int length;
    int width;
    int height;
    
    length= int.Parse(LengthtextBox.Text);
    width= int.Parse(WidthtextBox.Text);
    height= int.Parse(HeighttextBox.Text);
    paint = 350;
    
    answer = (length* width* height) / paint;
    

提交回复
热议问题