Hi,
Ques What is the Boxing and Unboxing in the .Net ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Mar 28, 2012, 11:39 PM
Boxing is converting an value type into object. The unboxing is converting an object type into value type.
There are two types in C#.
1) Reference Types
2) Value Types
Reference type is nothing but object type which is stored in the heap memory. The object will be cleared automatically from the memory when an object is no longer needed.
The value type is stored in the stack memory.
In C# the boxing happens implicitly.
For example
int i =10;
object obj = i; //Implicit type casting
Here the value type will be directly assigned to the object type.
If you want to convert an object type into value type
object obj = 10;
int i = (int) obj; //type casting (unboxing)
If you want to more infor then,
http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx
Sam HobbsPosted Mar 28, 2012, 10:51 PM