top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

what is the difference between boxing and unboxing in c#.net?

+1 vote
616 views
what is the difference between boxing and unboxing in c#.net?
posted Aug 4, 2014 by Arun

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

Boxing : Converting value type to object
Example :
int a=50;
object o=a;

UnBoxing: Converting object type to Value type
Example

object o=21;
int a=(int)o;

answer Aug 7, 2014 by Vinoth Kumar
converting a value type into a reference type is called boxing then, that reference type again converted to a value type is called un-boxing...
Boxing: int i=100;
obj obj=i;

Un-Boxing: int j= Convert.ToInt32(obj);
...