C # delegate Case

In C # (Delegate) commission is not to say, directly on the code, see the comments in the code:

namespace the Delegate 
{ 
    the delegate  void DGSayiHi ( String name); // declare a delegate 
    the delegate  void DGDO ( String name);
     class Program 
    { 
        static  void the Main ( String [] args) 
        { 
            DGSayiHi sayHi = new new DGSayiHi (SayChineseHi); 
            DGSayiHi sayhi2 = new new DGSayiHi (SayEnglishHi); 
            sayHi + = sayhi2; // actually equivalent + = Delegate.Combine, - = equivalent Delegate.Remove 

            sayHi ("春晓");
            Console.ReadLine();
        }
        static void SayChineseHi(string name)
        {
            Console.WriteLine("你好:" + name);
        }

        static void SayEnglishHi(string name)
        {
            Console.WriteLine("Hello:" + name);
        }

    }
}

Guess you like

Origin www.cnblogs.com/wml-it/p/12204098.html