Given an collection as 78, 92, 44, 63, 71, 97. The objective is to find the largest even number from the collection of numbers. The below program will do so
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new List<int>() { 78, 92, 44, 63, 71, 97 }
.TakeWhile(t => t % 2 == 0)
.OrderByDescending(o => o)
.First());
Console.ReadKey();
}
}
}
Output: 92