using System;
namespace ConsoleApp2
{
class Class21
{
public delegate void MethodCall();
public static event MethodCall MethodHandle;
static void Main(string[] args)
{
MethodHandle += Method;
MethodCall call = MethodHandle;
MethodHandle += MethodA;
call();
Console.Read();
}
public static void Method()
{
Console.WriteLine("调用了Method");
}
public static void MethodA()
{
Console.WriteLine("调用了MethodA");
}
}
}
MethodCall call = MethodHandle;
其实是call拷贝了一份委托链,之后的更改和它无关
call();修改为MethodHandle();
或者把MethodHandle += MethodA;写在前面