Saturday, 9 August 2014

Boxing and UnBoxing concepts in .net

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:
inti = 221;
object obj = i; //boxing
object obj = 213;
i = (int)obj ; // unboxing

class SenTest
{
               static void Main() {
                               int i = 1;
                               object o = i;                           // boxing
                               int j = (int) o;         // unboxing
               }
}


No comments:

Post a Comment