Hello All,
I'm trying to do what I would think would be simple and straightforward , but it is not. I have a 2 textbox on a form, a label, and a button, when I click the botton I want to add the 2 textboxes and place the value in the label. Unfortunately, when I try to convert.Int32(t xtBox1.Text) I get cannot convert string to int error. Basically, Im doing this:
int x;
int y;
x = (int) Convert.ToInt32 (TextBox1.Text) ;
y = (int) Convert.ToInt32 (TextBox2.Text) ;
lblTotal = x + y;
Error Message:
Error 1 Cannot implicitly convert type 'int' to 'string'
Can you help me understand why this does not work and what I can do to make it work. Thanks you!
I'm trying to do what I would think would be simple and straightforward , but it is not. I have a 2 textbox on a form, a label, and a button, when I click the botton I want to add the 2 textboxes and place the value in the label. Unfortunately, when I try to convert.Int32(t xtBox1.Text) I get cannot convert string to int error. Basically, Im doing this:
int x;
int y;
x = (int) Convert.ToInt32 (TextBox1.Text) ;
y = (int) Convert.ToInt32 (TextBox2.Text) ;
lblTotal = x + y;
Error Message:
Error 1 Cannot implicitly convert type 'int' to 'string'
Can you help me understand why this does not work and what I can do to make it work. Thanks you!
Comment