Linq Example 6 - Compound From

3:29 AM
Linq Query:

int[] myNumbers = { 0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 119, 129, 139, 149, 159 };
            //Query to find only even numbers that are smaller then 100

            var FinalNumbers =
                from evenNums in myNumbers
                where evenNums % 2 == 0 && evenNums < 100
                select evenNums;

            foreach (var t in FinalNumbers)
            {
                Console.WriteLine(t.ToString());
            }

Output:

0
22
44
66
88



0 comments:

Post a Comment