public void Run(object sender, CatShoutEventArgs args) { Console.WriteLine("我是{0},{1}來了,快跑!\n", Name, args.Name); if (run != null) { MouseRunEventArgs e = new MouseRunEventArgs(); //宣告事件參數 e.Name = this.Name; run(this, e); //事件Run觸發, 通知所有登記過的物件,並將發送通知的自己this以及參數Args傳遞出去 } }
public void Shout() { Console.WriteLine("我是{0}! 喵~ \n", Name); if (shout != null) { CatShoutEventArgs e = new CatShoutEventArgs(); e.Name = this.Name; shout(this, e); } }
public void Help(object sender, CatShoutEventArgs args) { Console.WriteLine("我是{0},{1}來了,救命啊!\n", Name, args.Name); }