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

Boxing Value Types

When working with value types, whether they are base data types, such as Integer, Long, or Double, or self-made structures, you never need to worry about the issues mentioned in the preceding sections, because you cannot inherit from value types.

There is one exception, however: all value types are derived from Object. While you can’t create an inheritance order based on a value type, Object and ValueType already exist in the inheritance order. This means that a variable of type Object should be able to refer to a value type. That sounds like a contradiction, but there’s a solution.

The .NET Framework solves this problem by using a special rule of the Common Type System (CTS), called boxing.

Note

“Boxing” refers to “putting into ...

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