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

Boxing and Unboxing

The common type system enables implicit conversions. It also enables conversions between reference types and value types—and vice versa—because both inherit from System.Object. You often need to work with two techniques, boxing and unboxing, when you have methods that receive arguments of type Object.

Boxing

Boxing occurs when you convert a value type to a reference type. In other words, boxing happens when you assign a value type to an Object. The following lines of code demonstrate boxing:

Dim calculation As Double = 14.4 + 32.12Dim result As Object = calculation

In this example, the calculation variable, which stores a value deriving from the sum of two numbers, is a Double value type. The ...

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