0 votes
in C Sharp by
What is Boxing and Unboxing?

1 Answer

0 votes
by

Boxing and Unboxing both are used for type conversion but have some difference:

Boxing - Boxing is the process of converting a value type data type to the object or to any interface data type which is implemented by this value type. When the CLR boxes a value means when CLR is converting a value type to Object Type, it wraps the value inside a System.Object and stores it on the heap area in application domain.

Unboxing - Unboxing is also a process which is used to extract the value type from the object or any implemented interface type. Boxing may be done implicitly, but unboxing have to be explicit by code.

The concept of boxing and unboxing underlines the C-Sharp unified view of the type system in which a value of any type can be treated as an object.

Related questions

0 votes
asked Jun 16, 2020 in C Sharp by Hodge
0 votes
asked May 6, 2020 in C Sharp by SakshiSharma
...