???????????????C#?????????????????÷?????????ο?????????????????????ü???????ü????????????????
?????????????????????????????????У???????????????????????????????????ж?????????????è?????????è?У???????????????????
?????????????????????к?????????????
????è??????????????????è?????????????è????????????????????????????????????????????????????????????è??????????????????????????????è????????????
???????????????£?
None.gifusing System;
None.gifusing System.Collections.Generic;
None.gifusing System.Text;
None.gifnamespace TestConsole
ExpandedBlockStart.gif{
InBlock.gif// ?????????У?????????????????è?????
InBlock.gifpublicdelegatevoid CatListeningHandler();
InBlock.gif
InBlock.gifpublicclass Cat
ExpandedSubBlockStart.gif{
InBlock.gif//?????????????????????è????
InBlock.gifpublicevent CatListeningHandler CatCry;
InBlock.gif
InBlock.gifpublicvoid Cry()
ExpandedSubBlockStart.gif{
InBlock.gif            Console.WriteLine("Meow~~");
InBlock.gif            OnCry();
ExpandedSubBlockEnd.gif        }
InBlock.gif
InBlock.gifprotectedvirtualvoid OnCry()
ExpandedSubBlockStart.gif{
InBlock.gifif (CatCry !=null)
ExpandedSubBlockStart.gif{
InBlock.gif                CatCry();
ExpandedSubBlockEnd.gif            }
ExpandedSubBlockEnd.gif        }
ExpandedSubBlockEnd.gif    }
InBlock.gif
InBlock.gifpublicclass Mouse
ExpandedSubBlockStart.gif{
InBlock.gifpublicvoid Run()
ExpandedSubBlockStart.gif{
InBlock.gif            Console.WriteLine("Mouse run awaydot.gif");
ExpandedSubBlockEnd.gif        }
ExpandedSubBlockEnd.gif    }
InBlock.gif
InBlock.gifclass Program
ExpandedSubBlockStart.gif{
InBlock.gifstaticvoid Main(string[] args)
ExpandedSubBlockStart.gif{
InBlock.gif            Cat cat =new Cat();
InBlock.gif
InBlock.gif            Mouse mouse =new Mouse();
InBlock.gif
InBlock.gif// ??è?к????????????????
InBlock.gif            cat.CatCry +=new CatListeningHandler(mouse.Run);
InBlock.gif
InBlock.gif            cat.Cry();
ExpandedSubBlockEnd.gif        }
ExpandedSubBlockEnd.gif    }
ExpandedBlockEnd.gif}
None.gif
????С??cat.CatCry +=new CatListeningHandler(mouse.Run)??CatListenningHandler???????У???????????????????????????????????CatCry?????е?????????+=??????????й????????????????????CatCry????????????mouse.Run()????С???????CatCry??????+=??????????????????????????????????з?????????С???????????в????????У?????-=???????????