Home »

Why only boxed types can be unboxed?

Question ListCategory: .NETWhy only boxed types can be unboxed?
milleranthony7 author asked 8 years ago
1 Answers
jessica537 author answered 8 years ago

Unboxing is the process of converting a Reference type variable to Value type and thus allocating memory on the stack . It happens only to those Reference type variables that have been earlier created by Boxing of a Value Type , therefore internally they contain a value type , which can be obtained through explicit casting . For any other Reference type , they don’t internally contain a Value type to Unboxed via explicit casting . This is why only boxed types can be unboxed .

Please login or Register to Submit Answer