Mega Code Archive

 
Categories / C# / LINQ
 

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");         }     } }