C#委托和事件
阿新 • • 發佈:2017-08-20
ng2 div log pan func fun str clas region
#region 委托、事件 static void ChineseGreeting(string name) { Console.WriteLine("早上好," + name); } static void EnglishGreeting(string name) { Console.WriteLine("Good Morning," + name); } delegate void GreetDelegate(stringname); 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#委托和事件