我刚开始学习C#。我正在开发一个最初的程序,我需要一些帮助。不确定原因,但我在尝试编译代码时遇到以下错误:< 39,48> CS0234命名空间“System”中不存在类型或命名空间“Event”。不确定编译器是读错了还是错误输入了什么。无论如何,看看这个,让我知道你的想法。谢谢!
using System;
using System.Windows.Forms;
namespace HelloWin
{
public class MyForm : Form
{
private TextBox txtEnter;
private Label lblDisplay;
private Button btnOK;
public MyForm()
{
this.txtEnter = new TextBox();
this.lblDisplay = new Label();
this.btnOK = new Button();
this.Text = "My HelloWin App!";
// txtEnter
this.txtEnter.Location = new System.Drawing.Point(16, 32);
this.txtEnter.Size = new System.Drawing.Size(264, 20);
// lblDisplay
this.lblDisplay.Location = new System.Drawing.Point(16, 72);
this.lblDisplay.Size = new System.Drawing.Size(264, 128);
// btnOk
this.btnOK.Location = new System.Drawing.Point(88, 224);
this.btnOK.Text = "OK";
this.btnOK.Click +=
new System.EventHandler(this.btnOK_Click);
// MyForm
this.Controls.AddRange(new Control[]{this.txtEnter, this.lblDisplay, this.btnOK});
}
static void Main ()
{
Application.Run(new MyForm());
}
private void btnOK_Click(object sender, System.Event.Args e)
{
lblDisplay.Text = txtEnter.Text + "\n" + lblDisplay.Text;
}
}
}
答案 0 :(得分:2)
删除System.Event .
Args e
...
private void btnOK_Click(object sender, System.EventArgs e)
...