using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LambdaSpace
{
public delegate void NoReturnNoPara();
class LambdaTest
{
public static void Show()
{
NoReturnNoPara method0 = new NoReturnNoPara(ShowSth);//.net1.1最原始的方法
NoReturnNoPara method1 = ShowSth;//简写的方法
NoReturnNoPara method2 = new NoReturnNoPara(
delegate()
{
Console.WriteLine("delegate show sth");
}
);//匿名方法的写法。很有用,有些回调函数可以
NoReturnNoPara method3 = new NoReturnNoPara(
()=>//箭头左边是参数,右边是方法体
{
Console.WriteLine("lambda show sth");
}
);//.net 3.0之后出现了lambda表达式
}
private static void ShowSth()
{
Console.WriteLine("show sth");
}
}
}