using System; namespace jimphei.drink{ class Pengyou//我的朋友的类型 { private string name; public string Name { get{return name;} set{name=value;} } public Pengyou(string n) { name=n; } } public delegate void DrinkDelegate(string winename,params Pengyou[] p);//喝酒的代理 class Drink { public void drinking(string food,params Pengyou[] ps)//具体的动作 { if(food==null) { Console.WriteLine("靠,没啤酒怎么喝啊"); } if(ps==null) { Console.WriteLine("走了,散场吧,下次再喝"); } foreach(Pengyou p in ps) { Console.WriteLine(p.Name+"喝"+food); } } static void Main()//在酒店的过程 { Pengyou jh=new Pengyou("剑辉"); Pengyou lp=new Pengyou("立鹏"); Pengyou yc=new Pengyou("育才"); Pengyou fy=new Pengyou("福元"); DrinkDelegate d=new DrinkDelegate(new Drink().drinking); d("雪津啤酒",jh,lp,yc,fy); Console.WriteLine("立鹏醉了,我们继续喝"); d("雪津啤酒",jh,yc,fy); Console.WriteLine("雪津被我们喝完了,我们继续喝青岛"); d("青岛啤酒",jh,yc,fy); d(null,null); } } }