using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 委托
{
class MulticastDeletate
{
public delegate void delegateFunction(string msg);
static void Main(string[] args)
{
MyClass mc=new MyClass();
delegateFunction df = new delegateFunction(mc.funciton1);//声明一个委托变量并绑定第一个委托方法
Console.WriteLine(df.Target);//委托实例对象
df += new delegateFunction(mc.function2);
df += new delegateFunction(mc.function3);
//
df -= new delegateFunction(mc.function2);//删除绑定的委托方法2
df("雪夜尘封的MuliticastDelegateDemo");
Console.ReadLine();
}
}
public class MyClass
{
public void funciton1(string msg)
{
Console.WriteLine("hellow1:{0}",msg);
}
public void function2(string msg)
{
Console.WriteLine("hellow2:{0}",msg);
}
public void function3(string msg)
{
Console.WriteLine("hellow3:{0}",msg);
}
}
}