Home > LINQ, Microsoft, Visual Studio > Use LINQ to query a List of String

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
Categories: LINQ, Microsoft, Visual Studio Tags:
  1. No comments yet.
  1. No trackbacks yet.
WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera