C#委托和事件

2021-09-22 10:13

阅读:874

标签:nat   ng2   region   lis   void   委托   事件   public   string    #region 委托、事件 static void ChineseGreeting(string name) { Console.WriteLine("早上好," + name); } static void EnglishGreeting(string name) { Console.WriteLine("Good Morning," + name); } delegate void GreetDelegate(string name); static void Greeting1(string name, GreetDelegate greetFunc) { greetFunc(name); } static void Greeting2()//绑定方法 { GreetDelegate dele1 = ChineseGreeting; dele1 += EnglishGreeting; Greeting1("Zheng", dele1); dele1 -= ChineseGreeting; dele1("Jonathan"); } //public event GreetDelegate del2; #endregion  C#委托和事件标签:nat   ng2   region   lis   void   委托   事件   public   string   原文地址:http://www.cnblogs.com/zxxxx/p/7400484.html


评论


亲,登录后才可以留言!