static void Main(string[] args) { //Heater heater = new Heater(); //Alarm alarm = new Alarm(); //heater.BoilEvent += alarm.MakeAlert;//注册方法 //heater.BoilEvent += (new Alarm()).MakeAlert;//给匿名对象注册方法 //heater.BoilEvent += Display.ShowMsg; //注册静态方法 //heater.BoilWater(); //Console.ReadKey(); BookStore store = new BookStore(); Customer c1 = new Customer(); BookHandler bookhandler = new BookHandler(c1.store_OnNewBook); Customer c = new Customer() Console.ReadKey(); }
public void Register(BookStore store) { store.OnNewBook += new BookHandler(store_OnNewBook); }