在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
private static void EnglishGreeting(string name) { Console.WriteLine("Morning, " + name); } private static void ChineseGreeting(string name) { Console.WriteLine("早上好, " + name); } static void Main(string[] args) { GreetingDelegate gd = EnglishGreeting; gd += ChineseGreeting; gd("多播调用"); Console.ReadKey(); }
例如,若要查询委托调用列表中方法的数量,你可以编写: int invCount= gd.GetInvocationList().Count();
移除指定绑定方法-= GreetingDelegate gd = EnglishGreeting; gd -= EnglishGreeting; gd += ChineseGreeting; gd("多播调用"); int invCount= gd.GetInvocationList().Count(); Console.WriteLine(invCount); Console.ReadKey();
如果移除已经移除的绑定方法 那么也不会报错
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论