---
title: "Value Type and Boxing"  
description: "The operation of converting value type to  reference type is called Boxing and the reverse operation is called Unboxing.  Boxingint Val =  1; //Value"  
author: "Anonymous User"  
published: 2010-07-17  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/33/value-type-and-boxing  
category: ".net"  
tags: ["c#", ".net"]  
reading_time: 1 minute  

---

# Value Type and Boxing

The operation of converting value type to reference type is called Boxing and the

reverse operation is called Unboxing.\

##### Boxing

int Val = 1; //Value type

Object Obj = Val; //Boxing

The first line we created a Value Type Val and assigned a value to Val. The second

line, we created an instance of Object Obj and assign the value of Val to Obj. This is

called Boxing

##### Unboxing

int i = (int)Obj; //Unboxing

Here we are converting a value of a Reference Type into a value of a Value Type. This

is called Unboxing.

Now, displaying the value of i.

```
MessageBox.Show("The value is   : " + i);
```

![Value Type and Boxing](https://www.mindstick.com/mindstickarticle/bc4f931a-3438-4448-b623-52648028fe86/images/8415ff35-718a-4632-b912-4424bcb29682.png)

---

Original Source: https://www.mindstick.com/articles/33/value-type-and-boxing

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
