public delegate void HandlerDelegate(int val);
public class Process
{
public static void Execute(HandlerDelegate del)
{
del(5);
}
}
class Program
{
static void Main(string[] args)
{
//HandlerDelegate handler = Task; normally I would do this first
Process.Execute(Task); // but this works - how?
}
public static void Task(int val)
{
Console.WriteLine(val);
}
}
我知道委托是对方法的引用,但是我如何能够将看起来像方法名称的东西传递给接受委托作为其参数的方法?