//声明一个可重写的OnPublish的保护函数 protected virtual void OnPublish(PubEventArgs e) { if (Publish != null) { //Sender = this,也就是Publisher this.Publish(this, e); } }
//对事件感兴趣的事情 public static void Receive(object sender, PubEventArgs e) { Console.WriteLine("幼稚,这么大了,还看《海贼王》,SB小明!"); Console.WriteLine("这个我定的《" + e.magazineName + "》,哇哈哈!"); }
//对事件感兴趣的事情 public static void Receive(object sender, PubEventArgs e) { Console.WriteLine("嘎嘎,我已经收到最新一期的《" + e.magazineName + "》啦!!"); }