Ejemplo n.º 1
0
 //public MarkGreeting delegate1;
 public void GreetPeople(string name, MarkGreeting delegate1)
 {
     //如果有方法注册委托变量
     if (delegate1 != null)
     {
         delegate1(name);//通过委托调用方法
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string       chineseName   = "小王";
            string       englishName   = "neil";
            MarkGreeting markGreeting1 = ChineseGreeting;
            MarkGreeting markGreeting2 = EnglishGreeting;

            //MarkGreeting mark2Greeting2 = EnglishGreeting;
            markGreeting1(chineseName);
            markGreeting2(englishName);
            //markGreeting1(englishName);
            Console.ReadKey();
        }
Ejemplo n.º 3
0
 public static void GreetPeople(string name, MarkGreeting markGreeting)
 {
     markGreeting(name);
 }