1:声明一个代理
public delegate int MyDelegate(int i, int k);
MyDelegate有2个参数i,k;同时返回的类型是Int
2:声明对应的代理函数
void Mothod1(int a,int b){
console.write(a+b);
}
3:实现代理的调用
static void Main(string[] args){
MyDelegate d1 = new MyDelegate(Method1);
//调用一
d1(1,2);//调用输出结果3
//调用二,调用Invoke
d1.Invoke(1,2);//输出结果3
//使用匿名方法调用
MyDelegate d2=new MyDelegate(delegate(int a,int b){return a+b;});
d2(1,2);//输出3
}