Boxing and unboxing is an important concept in C#. In C# there are three types of data type, value types (int, float), reference type (object, string) and pointer type. C# allows to convert vale type to reference type and vice versa. Boxing and unboxing enables to a unified view of type system in which any type of value can be treated as an object.
Boxing can be defined as a process of converting vale data type to a reference data type. It is used by object type and it is an implicit conversion. Value type and referenced type stored in stack and heap respectively.
For example
int num=23 ;
Object obj=num;
Unboxing can be defined as the process of converting reference type to value type. It is a reverse process of boxing and it as an explicit conversion.
For example
int num=23;
Object obj=num;
int i=(int)obj;
Liked By
Write Answer
Explain The Concept Of Boxing And Unboxing ?
MindStick Login
Join MindStick Community
You have need login or register for voting of answers or question.
Nishi Tiwari
13-Dec-2019Boxing and unboxing is an important concept in C#. In C# there are three types of data type, value types (int, float), reference type (object, string) and pointer type. C# allows to convert vale type to reference type and vice versa. Boxing and unboxing enables to a unified view of type system in which any type of value can be treated as an object.
Boxing can be defined as a process of converting vale data type to a reference data type. It is used by object type and it is an implicit conversion. Value type and referenced type stored in stack and heap respectively.
For example
Unboxing can be defined as the process of converting reference type to value type. It is a reverse process of boxing and it as an explicit conversion.
For example