Boxing: Converting a value type to an object
(reference type).
- Implicit conversion.
Unboxing: Converting an object
back to a value type.
- Explicit conversion.
Example:
int i = 123;
object obj = i; // Boxing
int j = (int)obj; // Unboxing
Boxing: Converting a value type to an object
(reference type).
Unboxing: Converting an object
back to a value type.
Example:
int i = 123;
object obj = i; // Boxing
int j = (int)obj; // Unboxing
Leave a Reply