---
title: "Differentiate between Boxing and Unboxing."  
description: "Differentiate between Boxing and Unboxing."  
author: "Sumit Kesarwani"  
published: 2014-09-02  
updated: 2020-09-19  
canonical: https://www.mindstick.com/interview/2113/differentiate-between-boxing-and-unboxing  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Differentiate between Boxing and Unboxing.

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.

## Answers

### Answer by Sumit Kesarwani

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.


---

Original Source: https://www.mindstick.com/interview/2113/differentiate-between-boxing-and-unboxing

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
