Home > DeveloperSection > Interviews > Differentiate between Boxing and Unboxing.

Posted on    September-02-2014 11:12 PM

 C# C# 
 1 Answer(s)
  722  View(s)
Rate this:

Sumit Kesarwani

Total Post:782

Posted on    September-02-2014 12:00 AM

When a value type is converted to an object type, the process is known as boxing; whereas, when an object type is converted to a value type, the process is known as unboxing.

Boxing and unboxing enable value types to be treated as objects. Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object. In this example, the integer variable i is boxed and assigned to object obj.

Don't want to miss updates? Please click the below button!

Follow MindStick