Write a program in VB.net to find the largest even number from a collection of numbers

Rajnilari2015
Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 222
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

Imports System.Collections.Generic
Imports System.Linq

Namespace ConsoleApplication2
Class Program
Private Shared Sub Main(args As String())

Console.WriteLine(New List(Of Integer)() From { _
78, _
92, _
44, _
63, _
71, _
97 _
}.TakeWhile(Function(t) t Mod 2 Is 0).OrderByDescending(Function(o) o).First())
Console.ReadKey()
End Sub
End Class
End Namespace


Output: 92

Comments or Responses

Login to post response