Google News
logo
.Net - Interview Questions
What is boxing and unboxing in .NET?
Boxing is the process of converting a value type into a reference type directly. Boxing is implicit.
 
Unboxing is the process where reference type is converted back into a value type. Unboxing is explicit.
 
An example is given below to demonstrate boxing and unboxing operations :
int a = 10;      // a value type
object o = a;     // boxing
int b = (int)o;   // unboxing
Advertisement