public delegate void Del(string message);
static void Main(string[] args)
{
#region 调用委托
Del handler = DelegateMethod;
handler("Hello World");
#endregion
#region 委托的异步回调
Program TestCallBack = new Program();
TestCallBack.MethodWithCallback(1, 2, handler);
#endregion
}
#region 一般调用委托的方法
public static void DelegateMethod(string message)
{
System.Console.WriteLine(message);
}
#endregion
#region 委托的异步回调的方法
public void MethodWithCallback(int param1, int param2, Del callback)
{
callback("The number is: " + (param1 + param2).ToString());
}
#endregion