What is boxing and unboxing in C#?

What is boxing and unboxing in C#?

Boxing: Boxing is a mechanism that is use for converting the value types (int,struct,enum) object into the reference type.

Object obj=3;

Boxing will wrap the value 3 into the heap object.

Unboxing: Unboxing is a mechanism that is use for converting the reference types(Class,Interface) into reference type.

Int x=(int) obj;

This x object assignment unwrap the value again.

Leave a Reply

Your email address will not be published. Required fields are marked *

5 + 1 =


All Rights Reserved 2019 | DesignzRush (OPC) Pvt. Ltd.
Inline
Inline