C# allows us to convert a Value Type to a Reference Type,and back again to Value Types.
The operation of Converting a Value Type to a Reference Type is called Boxing and the reverse operation is called Unboxing.
The operation of Converting a Value Type to a Reference Type is called Boxing and the reverse operation is called Unboxing.
Boxing
int Val = 1;
Object Obj = Val; // Boxing (value type to reference type)
UnBoxing
int Val = 1;
Object Obj = Val; // Boxing
int i = (int)Obj; // Unboxing (reference type to value type)
int Val = 1;
Object Obj = Val; // Boxing (value type to reference type)
UnBoxing
int Val = 1;
Object Obj = Val; // Boxing
int i = (int)Obj; // Unboxing (reference type to value type)
No comments:
Post a Comment
Comments