Export (0) Print
Expand All

8.6 Value Type Conversions

Visual Studio .NET 2003

Although interfaces are reference types, value types may be converted to and from them. When converting a value type to an interface, the value type is copied to the .NET Framework heap and a reference is returned. This reference is then converted to the interface type.

When converting an interface type to a value type, the value must be a null reference or an instance of the value type. Otherwise a System.InvalidCastException exception is thrown. The conversion copies the value on the .NET Framework heap to the stack and converts it to the value type. A null reference is treated as if it were the literal Nothing.

See Also

8.5 Array Covariance | 8.8 Widening Conversions | 8.9 Narrowing Conversions | 8. Conversions | Conversion Summary (Visual Basic Language Reference) | Array Conversions (Visual Basic Language Concepts)

Show:
© 2015 Microsoft