标签:介绍 3.0 匿名方法 style console oid [] span adl
首先,介绍匿名方法的发展史,以代码展示:
static void Main(string[] args) { //最原始的委托 TestDelegate testDelA = new TestDelegate(Method); //C# 2.0 后 Anonymous Method TestDelegate testDelB = delegate(string s) { Console.WriteLine(s); }; //C# 3.0 lambda TestDelegate testDelC = (s) => { Console.WriteLine(s); }; testDelA("Hello, this is a delegate!"); testDelB("This is a anonymous Method!"); testDelC("This is a lambda Method"); Console.ReadLine(); } static void Method(string s) { Console.WriteLine(s); }
标签:介绍 3.0 匿名方法 style console oid [] span adl
原文地址:http://www.cnblogs.com/birdofparadise/p/7078885.html