using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
public delegate void GreetingDelegate(string name);
private static void GreetingPeople(string name, GreetingDelegate makingGreeting)
{
makingGreeting(name);
}
private static void ChineseGreeting(string name)
{
Console.WriteLine("早上好,{0}\n", name);
}
private static void EnglishGreeting(string name)
{
Console.WriteLine("Good Morning,{0}\n", name);
}
static void Main(string[] args)
{
//* 调用委托方法一 *//
GreetingPeople("Shawn Chou", EnglishGreeting);
GreetingPeople("周先生", ChineseGreeting);
//* 调用委托方法二 *//
GreetingDelegate delegate1;
delegate1 = EnglishGreeting;
delegate1 += ChineseGreeting;
GreetingPeople("Shawn Chou", delegate1);
Console.ReadKey();
}
}
}