问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespacec井_Proj2_2{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender,EventArgse){}privatevoidbutton1_Click(objectsender,EventArgse){inta,b,c;a=Convert.ToInt16(textBox1.Text);b=Convert.ToInt16(textBox2.Text);c=a+b;textBox3.Text=Convert.ToString(c);}}}
解决方案
解决方案二:
textBox1.TexttextBox2.Text有内容么?里面的内容可以转换为int么
解决方案三:
检查textBox1和textBox2控件中是否有值。并且能够转换成Int16类型。//这是老师教你的吗?C井,人家叫CSharpnamespacec井_Proj2_2
解决方案四:
#=井
解决方案五:
具体错误是什么?textBox难道是TextBox?
解决方案六:
privatevoidbutton1_Click(objectsender,EventArgse){try{inta,b,c;a=Convert.ToInt16(textBox1.Text);b=Convert.ToInt16(textBox2.Text);c=a+b;textBox3.Text=Convert.ToString(c);catch(Exceptione){Console.WriteLine(e.Message);}}
解决方案七:
5楼忘了e已定义。。privatevoidbutton1_Click(objectsender,EventArgse){try{inta,b,c;a=Convert.ToInt16(textBox1.Text);b=Convert.ToInt16(textBox2.Text);c=a+b;textBox3.Text=Convert.ToString(c);catch(Exceptionex){Console.WriteLine(ex.Message);}}