Pages

Wednesday, May 22, 2013

Boxing and unboxing in C#

Boxing:

Boxing is the process of converting a value type to the reference type .
->it is implicit conversion type

sample code:

int i=1;
object obj=i; //boxing

unboxing:

Boxing is the process of converting a  reference type to the value type .
->it is explicit conversion type

sample code:


object obj=123;
 i=(int)obj; //unboxing



No comments:

Post a Comment