publicdelegatevoidDownStairDelegate();publicclassToolMan{publicstring Name {get;set;}//事件--受限制的委托--event本质上还是委托//限制一:只能出现在+=、-=的左侧//限制二:只能在内部调用publicDownStairDelegate DoList =null;publicToolMan(string name){
Name = name;}publicvoidDownStair(){
Console.WriteLine("工具人"+Name+"下楼了");if(DoList !=null){DoList();}}}
1.1.2 LazyMan.cs
usingSystem;namespacetest06{publicclassLazyMan{publicstring Name {get;set;}publicLazyMan(string name){
Name = name;}publicvoidTakeFood(){
Console.WriteLine("给"+Name+"外卖");}publicvoidTakePackage(){
Console.WriteLine("给"+Name+"快递");}}}