Use LINQ to query a List of String

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.