What is Boxing and Unboxing?
by Nithya[ Edit ] 2010-01-30 10:10:13
Boxing
Value Types are stored on the stack and Reference types are stored on the heap. The conversion of value type to reference type is known as boxing.
Example:
int i = 123;
object o = (object)i; // boxing
Unboxing
The conversion of reference type back to the value type is known as unboxing.
Example:
o = 123;
i = (int)o; // unboxing