Skip to Main Content
Visual Basic 2015 Unleashed
book

Visual Basic 2015 Unleashed

by Alessandro Del Sole
July 2015
Intermediate to advanced content levelIntermediate to advanced
1300 pages
87h 27m
English
Sams
Content preview from Visual Basic 2015 Unleashed

Elements Operators

Some extension methods enable you to get the instance of a specified item in a sequence. The first one is Single, and it gets the instance of only the item that matches the specified condition. The following code gets the instance of the only product whose product name is Mozzarella:

Try    Dim uniqueElement = products.Single(Function(p) p.                                        ProductName = "Mozzarella")Catch ex As InvalidOperationException    'The item does not existEnd Try

Single takes a lambda expression as an argument in which you can specify the condition that the item must match. It returns an InvalidOperationException if the item does not exist in the sequence (or if more than one element ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Visual Basic 2015

Beginning Visual Basic 2015

Bryan Newsome

Publisher Resources

ISBN: 9780134196664Purchase book