Lambda expression used to declare a delegate

image_pdfimage_print

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

class Program {
static void Main(string[] args) {
Func 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"); } } } [/csharp]

This entry was posted in LINQ. Bookmark the permalink.