Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            CountIt count = delegate
            {
                Console.WriteLine("I am in anonymous method");
            };


            count();

            ////////////////////////////////////////////////////////////////

            CountIt2 count2 = delegate(int p1)
            {
                Console.WriteLine("I am in anonymous method with parameter = " + p1);
            };


            count2(2);

            CountIt3 count3 = delegate(int x) {
                Console.WriteLine("I am in anonymous method with parameter = " + x);
                return(x + x);
            };


            int y = count3(2);

            Console.WriteLine("Y = " + y);
        }
Ejemplo n.º 2
0
        public static void Start()
        {
            CountIt2 count = delegate(int end) {
                for (int i = 0; i <= end; i++)
                {
                    Console.WriteLine(i);
                }
            };

            count(3);
            Console.WriteLine();
            count(5);
        }