C#实现的几种委托
//普通委托 DeleteShow ds = new DeleteShow(ShowName); Console.WriteLine("----------------------"); Console.WriteLine("普通委托----请输入用户名:"); string Name = Console.ReadLine(); Console.WriteLine(ds(Name)); Console.WriteLine("----------------------"); //匿名方法委托 DeleteShow ds2 = delegate(string NewName) { return string.Format("匿名方法委托----输入的用户名为:{0}", NewName); }; Console.WriteLine("----------------------"); Console.WriteLine("请输入用户名:"); string WriteName = Console.ReadLine(); Console.WriteLine(ds2(WriteName)); Console.WriteLine("----------------------"); //Lambada委托 DeleteShow ds3 = (LamName) => { return string.Format("Lambada委托----输入的用户名为:{0}", LamName); }; Console.WriteLine("----------------------"); Console.WriteLine("请输入用户名:"); string WriteLamName = Console.ReadLine(); Console.WriteLine(ds3(WriteLamName)); Console.WriteLine("----------------------");