using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace job1_01
{
   public partial class Form1 : Form
    {
       public Form1()
{
      InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
   int a,b;
label2.Text = "=";
a = int.Parse(textBox1.Text);
b = int.Parse(textBox2.Text);
label2.Text += a + b;
}
     }
}//截图在回复区c#

解决方案 »

  1.   

    winform 额...都没实例化这些对象,当然出错了.
      

  2.   

    你照抄书的吧?
    InitializeComponent();
    这种东西出现在VS设计窗体时自动生成的,
    你没有声明当然编译不过了
      

  3.   

    想深入了解Winform建议看看Form的Designer.cs中的内容。
      

  4.   


    vs的所见即所得的ide,会保存用户用鼠标拖拉(就像美工作画一样)来设计的部分。然后那些部分会自动编译为另一个public partial class Form1 : Form
        {
             private void InitializeComponent()
            {
               .......
            }        ................
        }
    也就是说成千上万行代码是vs自动生成的。如果你那么喜欢手动写代码,喜欢死抠一些代码而不喜欢使用高效率的开发工具,那么恐怕还是去学java、专门啃书本比较适合啊。还是下载免费的vs吧!http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products