/// <summary>
/// 多播委托就是将多个函数指向一个委托
/// </summary>
static void Main(string[] args)
{
del del1 = test1;
del1 += test2;
del1 += test3;
del1 -= test1; //取消函数test1的指向
del1();
Console.ReadKey();
}
static void test1() {
Console.WriteLine("我是test1");
}
static void test2()
{
Console.WriteLine("我是test2");
}
static void test3()
{
Console.WriteLine("我是test3");
}
调用结果:
我是test2 我是test3