Boxing and Unboxing is a essential concept in .Net’s type system. With Boxing and Unboxing one can link between value-types and reference-types by allowing any value of a value-type to be converted to and from type object.
Boxing
|
Unboxing
|
|
Definition:
|
Boxing is the process of converting a value type to the reference
type.
|
Unboxing is the process of converting
a reference type to value type
.
|
Type of Conversion:
|
Implicit Conversion
|
Explicit Conversion
|
Example:
|
int i = 221;
object obj = i; //boxing
|
object obj = 213;
i = (int)obj ; // unboxing
|
Nice post very helpful
ReplyDeletedbakings