LINQ Examples
To understand why LINQ is revolutionary, the best way is to begin with some code examples. In the next chapters, you see a huge quantity of code snippets, but this chapter offers basic queries to provide a high-level comprehension. Imagine you have a Person
class exposing the FirstName
, LastName
, and Age
properties. Then, imagine you have a collection of Person
objects, of type List(Of Person)
, called People
. Last, imagine you want to extract from the collection all Person
instances whose LastName
property begins with the letter D. This scenario is performed via the following code snippet that uses a LINQ query:
' "People" is of type List(Of Person)Dim peopleQuery = From pers In People Where ...
Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.