Boxing is an approach of converting a value type into a reference type.
int i =100;
object obj = i ; //Boxing
Unboxing is a process of converting a reference that is created through boxing back into a value type, but unboxing requires an explicit conversion.
int j = Convert.ToInt32(Obj);
Value Type =====> Reference Type // Valid (Boxing)
Value Type =====>Reference Type ===>Value Type // Valid (Unboxing)
Reference Type ==> Value Type //Invalid Operation.
Note :- You can not direct convert reference type to value type.
int i =100;
object obj = i ; //Boxing
Unboxing is a process of converting a reference that is created through boxing back into a value type, but unboxing requires an explicit conversion.
int j = Convert.ToInt32(Obj);
Value Type =====> Reference Type // Valid (Boxing)
Value Type =====>Reference Type ===>Value Type // Valid (Unboxing)
Reference Type ==> Value Type //Invalid Operation.
Note :- You can not direct convert reference type to value type.