Wednesday, October 31, 2007

What is boxing and unboxing?

Boxing and unboxing enables value type to be treated as object.Boxing allows a value type to stored in heap.Unboxing converts the object to value type.
Eg.
int
i = 123;
object o = (object)i; // boxing
o = 123;
i = (int)o; // unboxing

No comments: