您的位置:首页 > 其它

委托学习笔记:最简单的委托

2006-12-20 14:28 204 查看
using System;
using System.Collections.Generic;
using System.Text;

namespace 委托
{
class Program
{
public delegate void Del(string message);
//public delegate void SortDelegate(int[] SortArray);
public static void Show(string message)
{
Console.WriteLine(message);
}
static void Main(string[] args)
{
Del handler = new Del(Show);
handler("委托给Show");
MethodWithCallBack(1, 5, handler); //异步回调

}
public static void MethodWithCallBack(int param1,int param2,Del callback)
{
callback("the number is "+Convert.ToString(param1+param2));
}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: