首页 > 代码库 > 20140909_委托

20140909_委托

1. 定义委托

     public delegate void GreenPeople(string name);

2. 声明方法

     public static void ChinesePeople(string Name)
     {
         Console.WriteLine("你好," + Name);
     }
     public static void English(string Name)
     {
         Console.WriteLine("Hello," + Name);
     }

3. 声明将委托做为参数进行

        public static void Print(string Name,GreenPeople greenPeople)
        {
            greenPeople(Name);
        }

4. 执行使用

   Print("刘德华", ChinesePeople);

20140909_委托