Lambda expression used to declare a delegate : Lambda : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » Lambda »

 

Lambda expression used to declare a delegate








    
 

using System;
using System.Linq;
using System.Linq.Expressions;

class Program {
    static void Main(string[] args) {
        Func<int, bool> isOddDelegate = i => (i & 1) == 1;
        for (int i = 0; i < 10; i++) {
            if (isOddDelegate(i))
                Console.WriteLine(i + " is odd");
            else
                Console.WriteLine(i + " is even");
        }

    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» Lambda