您的位置:首页 > 编程语言 > C#

C#中委托使用一

2010-04-03 10:31 316 查看
namespace delegatee
{
/// <summary>
/// 声明一个委托
/// </summary>
/// <param name="name"></param>
public delegate void DoGreeting(string name);
class Program
{
private static void Englishhello(string name)
{
Console.WriteLine("hello,{0}",name);
}
private static void Chinesehello(string name)
{
Console.WriteLine("你好,{0}", name);
}
private static void Greethello(string name,DoGreeting makehello)
{
makehello(name);
}

static void Main(string[] args)
{
Greethello("Tom", Englishhello);
Greethello("李", Chinesehello);
Console.ReadLine();
}

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