Use LINQ to query a List of String

LINQ (Language Integrated Query) is cool. I just wrote a little sample to query a List of String.

Private coolPeople As New List(Of String)()
 
Sub Main()
coolPeople.Add("Christoph")
coolPeople.Add("Christian")
coolPeople.Add("Hans")
coolPeople.Add("Flurina")
coolPeople.Add("Angie")
coolPeople.Add("Paul")
 
Dim query As IEnumerable(Of String) = From p In coolPeople Select p _
Where p.Length > 5 _
Order By p
For Each person As String In query
Console.WriteLine(person)
Next
Console.ReadLine()
 
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *