Find a Nth highest or lowest numbers in a given series of integers using indexing technique in VB.net

Rajnilari2015
Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 102
Imports System.Collections.Generic
Imports System.Linq

Namespace ConsoleApplication2
Class Program
Private Shared Sub Main(args As String())
'Question #3: Find a Nth highest or lowest number in a given series of numbers.
Dim lstNumbers As New List(Of Double)() From { _
1, _
2.06, _
-36.4, _
-4, _
5.9, _
618.9, _
79.8, _
8, _
9, _
18.0, _
23.7 _
}

Dim itemsCount As Integer = lstNumbers.Count
Dim sortedList = lstNumbers.OrderBy(Function(o) o).ToList()
Dim minNum As Double = sortedList(0)
Dim maxNum As Double = sortedList(itemsCount - 1)
Console.WriteLine("Min = {0} , Max = {1}", minNum, maxNum)
End Sub
End Class
End Namespace

Comments or Responses

Login to post response