Header Ads

Boxing VS Unboxing

Boxing_VS_Unboxing

BoxingUnboxing
Convert to value type to reference type.Convert to reference type to value type.
Boxing is used to store the value types in the garbage collected as a Heap.Unboxing an interface type to a value type that implements the interface.
Implicit conversion.Explicit conversion.
Ex:
int i = 100;
object obj = i;
Ex:
int i = 100;
object obj = i;
int j =(int)obj;

No comments:

Powered by Blogger.