Using Take to get only the first 3 elements of the array : Take « LINQ « VB.Net






Using Take to get only the first 3 elements of the array

  


Imports System.IO
Imports System.Reflection
Imports System.Linq
Imports System.Xml.Linq

Public Class MainClass
   Public Shared Sub Main


        Dim numbers() As Integer = {5, 4, 1, 3, 9}

        Dim first3Numbers = From num In numbers Take 3

        Console.WriteLine("First 3 numbers:")
        For Each n In first3Numbers
            Console.WriteLine(n)
        Next
   End Sub


End Class

   
    
  








Related examples in the same category

1.Get the top 5 memory-using applications currently loaded
2.Indexed Take While
3.Alternative syntax for Take While
4.Take Partitioning