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();
}
}
}
{
/// <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();
}
}
}
相关文章推荐
- C#使用委托的简单步骤
- c#中时间和委托的 adbb 使用
- c#打包文件解压缩 C#中使用委托、接口、匿名方法、泛型委托实现加减乘除算法 一个简单例子理解C#的协变和逆变 对于过长字符串的大小比对
- [泛型委托]-C# 三种泛型委托的使用
- C#中使用委托和事件实现观察者模式(observer pattern)
- C#中事件和委托的使用
- cocos2d-x系列笔记(9.1)---浅谈cocos2d-x使用函数指针实现委托(上)---通过c#代码理解委托
- C#中使用委托卖房案例
- C#中使用委托
- C# EventHandler and Delegate(委托的使用)
- 一个程序帮助你熟悉和使用C#中委托和事件
- C#中对委托的理解和使用
- C#中委托(Delegates)的使用方法详解
- C# 使用委托调用待待闪屏
- 15 C# 第十三章 事件和委托(二) 使用事件
- c#事件处理中事件信息EventArgs的使用和类型内部事件委托delegate的调用
- paip.c#使用匿名函数建立委托提高可读性
- C# 下使用委托跨窗体调用函数和控件的实现
- C# 委托使用详解(delegate)