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("----------------------");

 

posted @ 2013-02-28 20:26  踏浪帅  阅读(400)  评论(0编辑  收藏  举报