A very simple program that displays the odd digits in LINQ:
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace TestLinQ{class Program
{static void Main(string[] args)
{ // declare an array of integers int[] digits = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // find all odd digits var oddDigits = from n in digits where n % 2 == 1 select n; // display all odd digitsforeach(var x in oddDigits)
{ Console.WriteLine(x);}
}
}
}

0 comments:
Post a Comment