//委托定义
public delegate void HelloOne();
public delegate string HelloTwo(string input);
class Program
{
static void Main(string[] args)
{
//普通委托
HelloOne helloOne = SayHello;
helloOne();
HelloTwo helloTwo = SayHello;
Console.WriteLine(helloTwo("xxx"));
//Action,Func 委托(Action适用于方法无返回值)
Action actionOne = SayHello;
actionOne();
Action<string> actionTwo = SayHelloTwo;
actionTwo("...");
Func<string,string> func = SayHello;
Console.WriteLine(func("..."));
Console.ReadLine();
}
public static string SayHello(string input)
{
return "SayHello(string input):" + input;
}
public static void SayHello()
{
Console.WriteLine("SayHello()");
}
public static void SayHelloTwo(string input)
{
Console.WriteLine("SayHello():" + input);
}
}