委托

C#委托(Delegate)
委托(Delegate)特别用于现实事件和回调方法,所有的委托(Delegate)都派生自System.Delegate类。
委托:例如小明叫小张买车票
委托多播:例如小明叫小张买完车票,之后有接着又让他帮买张电影票。
委托声明: public delegate int MyDelegate (string s);
语法: delegate<return type> <delegate_name> <parameter list>
实例化委托:
public delegate void printString(string s);
......
printString ps1 = new printString(WriteToScreen);
printString ps2 = new printString(WriteToFile);

posted @ 2018-03-19 09:20  蒲公英的约定&h  阅读(122)  评论(0编辑  收藏  举报