Monday, June 8, 2009

What is Boxing & Unboxing

Converting a value type to reference type is called Boxing
int i =5;
string mystring = i.ToString(); //This is boxing as string is reference type
Converting a reference type to value type is called Unboxing
int x= Convert.ToInt32(mystring); //This is unboxing
Boxing & Unboxing is a link between value type & reference type.
For more information Refer:

No comments: