日期:2014-05-17 浏览次数:20829 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DelDemo
{
/// <summary>
/// 这是一个委托,让某人说某句话
/// </summary>
/// <param name="name">名字</param>
/// <param name="words">要说的话</param>
internal delegate void SaySth(string name,string words);
class Program
{
static void Main(string[] args)
{
SaySth s = new SaySth(Shout);
s("GT", "good luck to me!");
Console.WriteLine(s.GetHashCode());
s = Cry;
s("GT", "aewfawf");
Console.WriteLine(s.GetHashCode());
Console.ReadKey();
}
/// <summary>
/// 喊话
/// </summary>
/// <param name="name"></param>
/// <param name="words"></param>
static void Shout(string name, string words)
{
Console.WriteLine("i'm {0},and i said {1}", name, words);
Console.ReadKey();
}
/// <summary>
/// 哭泣
/// </summary>
/// <param name="name"></param>
/// <param name="why"></param>
static void Cry(string name, string why)
{
Console.WriteLine("i'm {0} , i'm crying bacuse {1}", name, why);
Console.ReadKey();
}
}
}