Example #1
0
        public static void Main()
        {
            DelegateClass obj = new DelegateClass();
            DelegateOne   d1  = new DelegateOne(obj.MethodA);
            DelegateTwo   d2  = new DelegateTwo(obj.MethodB);

            d1();   // invoke MethodA() in DelegateClass
            d2(10); // invoke MethodB(10) in DelegateClass
        }
Example #2
0
        static void Main(string[] args)
        {
            DelegateOne En = (x) => x * 2;

            Console.WriteLine(En(12));

            DelegateTwo To = (x, y, z) => x + y + z;

            Console.WriteLine(To(2, 4, 6));

            DelegateThree Tre = () => "Hello World";

            Console.WriteLine(Tre());

            Console.ReadLine();
        }