Skip to Content
Visual Basic 2015 Unleashed
book

Visual Basic 2015 Unleashed

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

The Null-Conditional Operator and Collections

In Chapter 4, “Data Types and Expressions,” and in Chapter 14, “Generics and Nullable Types,” you learn a little about the new null-conditional operator. Visual Basic 2015 allows you to use this operator against collections, too. You can definitely use the ?. operator to check whether a collection is null before using it, but you can also take advantage of a special syntax that supports indexing. For example, the following code demonstrates how to retrieve the first item from a list of integers only if the collection is not null:

Function GetList() As List(Of Integer)    Return New List(Of Integer) From {1, 2, 3}End FunctionSub NullCheckDemo()    Dim x As List(Of Integer) ...

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