this.button1.Click += new System.EventHandler(delegate(object sender, System.EventArgs e) { this.Close(); });
void button1_Click(object sender, EventArgs e){this.Close();}
事件的绑定一般是这样,用委托和lambda表达式,可以将之简化。
委托:
this.button1.Click += new System.EventHandler(delegate(object sender, System.EventArgs e) { this.Close(); });
lambda表达式:
this.button1.Click += (ss, arg) => { this.Close(); };