O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Combining LINQ Extension Methods

As you are by now familiar with a few of the most important LINQ extension methods, here’s a brief look at how these methods interact.

All these methods return collections that have something in common; just like the source collections on which they are based, the methods implement IEnumerable(Of T). Serendipitously, that also means that the result collection returned by the extension methods can be used as the argument for another LINQ extension method; in other words, you can chain them together, as illustrated in the following example:

Public Sub CombinedExtensionmethods()

    Dim resultList = contacts.Where(
       Function(oneContact) oneContact.location = "Bremen").Select(Function(oneContact)
       New With {.ID = oneContact.ID, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required