private void UnRegisterEvent() { foreach (Animal mAni in aniArr) { if (mAni is MachineCat) { MachineCat mCat = (MachineCat)mAni; mCat.RemoveAllEvent(); } } }
private void RegisterEvent() { foreach (Animal mAni in aniArr) { if (mAni is MachineCat) { MachineCat mCat = (MachineCat)mAni; mCat.RemoveAllEvent(); foreach (Animal ani in aniArr) { if ((ani is Cat) && !(ani is MachineCat)) { Cat cat = ani as Cat; mCat.change += new MachineCat.ChangeEventHandler(cat.Clap); } } } } }