VB.net Program to find the numbers between a range

Rajnilari2015
Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 275
Let's say we have a collection as { 16, 17, 4, 3, 5, 2,10 }. Given a range 2,10 we need to find out the numbers between the range. The range values are inclusive. The below program will do so

Imports System.Collections.Generic
Imports System.Linq

Namespace ConsoleApplication2
Class Program
Private Shared Sub Main(args As String())
Dim intList = New List(Of Integer)() From { _
16, _
17, _
4, _
3, _
5, _
2, _
10 _
}
Dim lowerRange = 2
Dim upperRange = 10

intList.Where(Function(w) w >= 2 AndAlso w <= 10).OrderBy(Function(o) o).ToList().ForEach(Function(i) Console.WriteLine(i))

Console.ReadKey()
End Sub
End Class
End Namespace


Result
-------

2
3
4
5
10

Comments or Responses

Login to post response