在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
{ static void Main(string[] args) { Boss boss = new Boss(); Charge c = new Charge(); Employee emp = new Employee(); //订阅事件 emp.PlayGame += new Employee.JoinPlayGame(c.StopGame); emp.PlayGame+=new Employee.JoinPlayGame(boss.YourOver); Console.WriteLine("Game?"); if(Console.ReadLine().Equals("Yes")) emp.StartGame(); else Console.WriteLine("After you are the boss!"); } } class Employee { public delegate void JoinPlayGame(); public event JoinPlayGame PlayGame; public void StartGame() { if (PlayGame != null) PlayGame(); } } class Boss { public void YourOver() { Console.WriteLine("Out!"); } } class Charge { public void StopGame() { Console.WriteLine("StopGame!"); } } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论