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

Understanding Implicit Conversions

Previously we discussed the System.Object class. As you might remember, this class is the root in the class hierarchy. That said, you can assign both reference types and value types to an Object instance because they both inherit from System.Object. Consider the following lines of code:

Dim anInt As Object = 10Dim onePerson As Object = New Person

The first line assigns a value type (Integer) to an Object, and the second one assigns an instance of the Person class to an Object. Visual Basic 2015 always enables such assignments because they are always safe. However, it is unsafe to try to assign an Object to a strongly typed instance, such as an instance of the Person class. This ...

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