Hello all. I am used to using Write and WriteLine when trying to display my results using the COnsole.
Now working with windows applications, I am trying to display the results in a textbox but keep coming up with the wrong thing.
It should say:
The sum of [integer entered by the user in txtfirst textbox] and [integer entered by user in the txtsecond textbox] is: [displays answer here in txtanswer]
What it DOES say is:
The sum of System.Windows. Form.
I don't understand why I am getting that.
Here is the code for btnadd. Can someone give me some guidance please?
Now working with windows applications, I am trying to display the results in a textbox but keep coming up with the wrong thing.
It should say:
The sum of [integer entered by the user in txtfirst textbox] and [integer entered by user in the txtsecond textbox] is: [displays answer here in txtanswer]
What it DOES say is:
The sum of System.Windows. Form.
I don't understand why I am getting that.
Here is the code for btnadd. Can someone give me some guidance please?
Code:
private void btnadd_Click(object sender, System.EventArgs e) { string inValue; string inValue2; double firstNum; double secondNum; double add; inValue = txtfirst.Text; inValue2 = txtsecond.Text; firstNum = double.Parse(inValue); secondNum = double.Parse(inValue2); add = (firstNum + secondNum); txtanswer.Text = string.Format("The sum of {0} and {1} is: {2}", txtfirst, txtsecond, add).ToString(); }
Comment