+92 332 4229 857 99ProjectIdeas@Gmail.com

Enumerable Range() Method (Vb.net)



The following code shows how to generate a sequence of numbers and then applying query on it. See the code below.








In this first, generating a sequence from 1 to 10 and selecting each value in array and square it and display.


Dim number As IEnumerable(Of Integer) = _
           Enumerable.Range(1, 10).Select(Function(x) x * x)

    For Each i In number
        Console.Write(i & " ")
    Next

Output of the program is:
1 4 9 16 25 36 49 64 81 100 

Second Scenario,

Dim number() As Integer = Enumerable.Range(1, 10).ToArray()

Dim query = _
    number.Select(Function(x) x * x)

      For Each i In query
          Console.Write(i & " ")
      Next

Output of the program is:
1 4 9 16 25 36 49 64 81 100 
 
see this in c#.net

0 comments: