Thursday, April 30, 2009

What is Boxing and Unboxing in .net?

Boxing:
It is a process of converting value type into Reference Type.

UnBoxing:
It is a reverse process of Boxing i.e. Converting Reference Type
into Value Type.

Here is the Example :

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

No comments:

Post a Comment