コード例 #1
0
        static void Main(string[] args)
        {
            Program p = new Program();

            // create instance of delegates
            AddDelegate ad = new AddDelegate(Program.Add);
            AddName     an = new AddName(p.Name);
            AddJob      aj = new AddJob(Program.Job);// normal call also applicable , keeping Class Name by calling is optional

            // in case of static methods

            // now call the delegate , by pass the value so that the method which is bound with delegate internally should execute
            ad(100, 200);
            ad.Invoke(2000, 20200);
            an.Invoke("laxman");
            an("shukla");
            string s1 = aj("ved");
            string s  = aj.Invoke("praksh");

            Console.WriteLine(s1);
            Console.WriteLine(s);
            Console.WriteLine("Complete");
            Console.Read();
        }