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

            obj.Invoke(100, 50);
            MulDelegate obj1 = new MulDelegate(Mul);

            obj1.Invoke(50);
            Console.ReadLine();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //  instantiate a delegate
            AddSumDelegate obj = delegate(int a, int b)
            {
                Console.WriteLine(a + b);
            };

            //GreetinsDelegate1 obj1 = delegate (string n)
            //{
            //    return "This is " + n + "Method";
            //};
            //Method is value returning method

            //obj.Invoke(100,15);
            //string strr = obj1.Invoke("mm");
            //Console.WriteLine(a +b);
            //Console.WriteLine(strr);
            obj.Invoke(100, 15);
            //string strr = obj1.Invoke("mm");
            //Console.WriteLine(a + b);
            Console.ReadLine();
        }