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