public void Cry() { Console.WriteLine(cName + "来了"); Console.ReadLine(); //用这个保存参数 CryEventArgs e = new CryEventArgs(); e.CatName = cName; //触发事件,带参数 CatCryEvent1(this, e); }
private void Run(object sender, CryEventArgs e) { if (e.CatName == "Tom") { Console.WriteLine("别怕,是Tom这只傻猫"); Console.ReadLine(); } else { Console.WriteLine("快跑啊,是其他猫!"); Console.ReadLine(); } }