我表述的有点问题 看下面代码MethodClass obj = new MethodClass(); Del d1 = obj.Method1; Del d2 = obj.Method2; Del d3 = DelegateMethod;//Both types of assignment are valid. Del allMethodsDelegate = d1 + d2; allMethodsDelegate += d3;参考
可以不用初始化事件就直接用+=操作符绑定方法,可绑定多个 如 public delegate void MyDelegate(); MyDelegate a = F1;初始化事件 a += F2; a();
比如说string t ="212"; t+="23"; 那么t就是21223 这时。 t="24",那么前面的21223全部没有了,只有24. 委托也是这个道理。
看下面代码MethodClass obj = new MethodClass();
Del d1 = obj.Method1;
Del d2 = obj.Method2;
Del d3 = DelegateMethod;//Both types of assignment are valid.
Del allMethodsDelegate = d1 + d2;
allMethodsDelegate += d3;参考
如
public delegate void MyDelegate();
MyDelegate a = F1;初始化事件
a += F2;
a();
t+="23";
那么t就是21223
这时。
t="24",那么前面的21223全部没有了,只有24.
委托也是这个道理。