BOXING:
Converting a value type to a reference type object is called boxing. A value type is stored on stack memory and requires conversion-boxing-to an object on the heap memory before it can be treated as an object. The members of the new object can be invoked on the value, eg., coverting a double to a string. Boxing may be performed implicitly at runtime by the CLR.
int m=10;
object om=m;
m=20;
Console.WriteLine(m);//
m=20;
Console.WriteLine(om);//om=10
UNBOXING
Conversion of a referenced typed object to the associated value type instance. Usually , Unboxing is performed explicitly by a cast operation. Ex:
int m=10;
object om=
m; int n=
(int) om;
Converting a value type to a reference type object is called boxing. A value type is stored on stack memory and requires conversion-boxing-to an object on the heap memory before it can be treated as an object. The members of the new object can be invoked on the value, eg., coverting a double to a string. Boxing may be performed implicitly at runtime by the CLR.
int m=10;
object om=m;
m=20;
Console.WriteLine(m);//
m=20;
Console.WriteLine(om);//om=10
UNBOXING
Conversion of a referenced typed object to the associated value type instance. Usually , Unboxing is performed explicitly by a cast operation. Ex:
int m=10;
object om=
m; int n=
(int) om;
No comments:
Post a Comment