Conversion of boxed value types

suggest change

Boxed value types can only be unboxed into their original Type, even if a conversion of the two Types is valid, e.g.:

object boxedInt = (int)1; // int boxed in an object

long unboxedInt1 = (long)boxedInt; // invalid cast

This can be avoided by first unboxing into the original Type, e.g.:

long unboxedInt2 = (long)(int)boxedInt; // valid

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents