delegate
- 委托:将方法作为变量或参数进行传递,并以方法的形式进行执行;
public delegate void SayHelloFunc(string name);
namespace CPlusLesson
{
class Test01
{
static void Main(string[] args)
{
SayHelloFunc hel = SayHelloName;
hel("张三");
Console.ReadKey();
}
public static void SayHelloName(string name)
{
Console.WriteLine("你好啊!" + name);
}
}
}

委托链
class Test01
{
static void Main(string[] args)
{
SayHelloFunc hel = SayHelloName;
hel += SayHelloPople;
hel("张三");
Console.ReadKey();
}
public static void SayHelloName(string name)
{
Console.WriteLine("你好啊!" + name);
}
public static void SayHelloPople(string p)
{
Console.WriteLine("你好啊!" + p+"老师");
}
}
