Thursday, March 15, 2012

Boxing and unboxing in c#

Boxing is the process of conversion of a variable to object where as unboxing is the process of conversion of object to variable


C#
int i = 123;
object o = (object)i;  // boxing

C#
o = 123;
i = (int)o;  // unboxing