Use a loop to print out each value in Linq query result : Select « LINQ « VB.Net






Use a loop to print out each value in Linq query result

   


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

Public Class MainClass
   Public Shared Sub Main
        Dim numbers = New Integer() {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
        Dim lowNums = From num In numbers Where num < 5 Select num
        Console.WriteLine("Numbers < 5:")
        For Each lowNumber In lowNums
            Console.WriteLine(lowNumber)
        Next
   
   End Sub


End Class

   
    
    
  








Related examples in the same category

1.Add vbCrLf to the selected value
2.Renaming property in Select
3.Using Select to return a sequence of project names
4.Query Date with Linq
5.Query Reuse with deferred execution
6.Using Concat to create one sequence that contains each array's values
7.Using an indexed SelectMany clause
8.Using Concat to create one sequence
9.Using linq to query the Registry
10.Shows all keys under HKLM\Software that start with the letter C
11.Shows shortcuts to everything under My Recent Documents
12.Counts how many items are in your Favorites folder
13.Uses reflection to show all System assemblies which are currently loaded
14.Projecting Select
15.Using Select to produce a sequence of Integers one value higher
16.Transformation Select
17.Using Select to produce a sequence of strings from a sequence of Integers
18.Anonymous Types in Select Clause
19.Using Select to produce a sequence of each word in an array with new case.
20.Using 'Select New With' to create new objects
21.Using Select to produce a sequence of new objects from two arrays with calculation
22.Using an indexed Select clause to determine if the value of Integers match their position
23.Combine Select and Where to get value from an array based on the value from another array
24.Check for the second letter from each word in an array
25.num is called the range variable which will take turns representing each value in the array.
26.Select with Function