class Program
{
delegate void MyDelegate(string str);
static void Main(string[] args)
{
//正常调用
MyDelegate myDelegate = new MyDelegate(CW);
myDelegate("正常调用");
//匿名函数
MyDelegate myDelegate2 = delegate (string str) { Console.WriteLine(str); };
myDelegate("匿名函数");
//Lambda表达式
MyDelegate myDelegate3 = (string str) => { Console.WriteLine(str); };
myDelegate3("Lambda表达式");
Console.ReadKey();
}
static void CW(string str)
{
Console.WriteLine(str);
}
}
来源:https://www.cnblogs.com/xiaobao2017/p/12204320.html