Thursday, December 3, 2015

C# Generics, Lamda Expression, Anonymous delegates, Extensions.

Next time you get chance to write a code.. use action as procedure to do your task.
Recursive Lamda Expression
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Action countdown = null;
            countdown = (i) =>
            {
                if (i > 0)
                {
                    Console.WriteLine(i);
                    countdown(i - 1);
                }
            };
            countdown(5);
            Console.Read();
        }
    }
}

No comments :