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 *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">