标签:
1 //声明委托 2 public delegate void StartClockDelegate(); 3 public delegate void StopClockDelegate(); 4 //创建委托实例 5 public StartClockDelegate StartClocks; 6 public StopClockDelegate StopClocks; 7 //通过调用委托调用方法 8 public void StartClockRunning() 9 { 10 this.StartClocks(); 11 } 12 public void StopClockRunning() 13 { 14 this.StopClocks(); 15 } 16 17 18 //将方法加到委托中 19 controller.StartClocks += localClock.StartLocalClock; 20 controller.StartClocks += londonClock.StartEuropeanClock; 21 controller.StartClocks += newYorkClock.StartAmericanClock; 22 controller.StartClocks += tokyoClock.StartJapaneseClock; 23 controller.StopClocks += localClock.StopLocalClock; 24 controller.StopClocks += londonClock.StopEuropeanClock; 25 controller.StopClocks += newYorkClock.StopAmericanClock; 26 controller.StopClocks += tokyoClock.StopJapaneseClock;
标签:
原文地址:http://www.cnblogs.com/wangzianan/p/4181069.html