Boxing and Unboxing in C#

Category > CSHARP || Published on : Wednesday, March 24, 2021 || Views: 1518 || Boxing and Unboxing in C#


Here Pawan Kumar will explain how to Boxing and Unboxing in C#

Boxing is the term used to describe the transformation of a value type to a reference type.

int x = 100;
object obj = x; 

Unboxing is the term used to transformation of a value type to a reference type.

int x = 50; 
object obj = x; // Box the int
int y = (int)obj; // Unbox it back into an int