---
title: "What is Boxing and Unboxing in C#"  
description: "What is Boxing and Unboxing in C#"  
author: "Niraj Kumar Mishra"  
published: 2017-08-24  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/23289/what-is-boxing-and-unboxing-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# What is Boxing and Unboxing in C#

**Boxing :****\****Boxing** is the process of converting a *value type* to the *object* *type*.When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the managed heap.\
**Example** :\

```
int i = 123;    // The following line indicates the boxing of i.object o = i;
```

**Unboxing :**\
**Unboxing** is an explicit conversion from the type *object* to a *value type*\

```
 o = 123;// The following line indicates the unboxing of o. i = (int)o;
```

## Answers

### Answer by Niraj Kumar Mishra

**Boxing :****\****Boxing** is the process of converting a *value type* to the *object* *type*.When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the managed heap.\
**Example** :\

```
int i = 123;    // The following line indicates the boxing of i.object o = i;
```

**Unboxing :**\
**Unboxing** is an explicit conversion from the type *object* to a *value type*\

```
 o = 123;// The following line indicates the unboxing of o. i = (int)o;
```


---

Original Source: https://www.mindstick.com/interview/23289/what-is-boxing-and-unboxing-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
