1.事件

通常写法(C# 1.0)

this.button.Click +=new EventHandler(button_Click); 

void button_Click(object sender, EventArgs e) 
{ 
     throw new NotImplementedException(); 
} 

在C#2.0中使用匿名方法

this.button.Click +=delegate{
throw new NotImplementedException(); 

}; 
//或者 
this.button.Click +=delegate(object obj, EventArgs args)

   throw new NotImplementedException(); 

}; 

使用Lamba表达式

this.button.Click += (s, ev) => { throw new NotImplementedException(); }; 

2.一般委托

 

 Func<int,int,int> max=(a,b)=>
 {
     if (a > b)
        return a;
      return b;
  };      
  int rst=max(222,134);
  Console.Write(rst)

参考自http://www.cnblogs.com/neozhu/archive/2010/07/16/1778864.html

相关文章:

  • 2021-12-16
  • 2021-08-08
  • 2021-06-17
  • 2021-09-27
  • 2021-12-27
  • 2021-07-31
  • 2022-01-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-12-13
  • 2022-02-04
相关资源
相似解决方案