C# | Boxing And Unboxing
Boxing and unboxing are important concepts in C# . The C# Type System contains three data types : Value Types (int, char, etc) , Reference Types (object) and Pointer Types . Basically, Boxing converts a Value Type variable into a Reference Type variable, and Unboxing achieves the vice-versa. Boxing and Unboxing enable a unified view of the type system in which a value of any type can be treated as an object. Boxing In C# The process of converting a Value Type variable (char, int etc.) to a Reference Type variable (object) is called Boxing . Boxing is an implicit conversion process in which object type (super type) is used. Value Type variables are always stored in Stack memory, while Reference Type variables are stored in Heap memory. Example : int num = 23; // 23 will assigned to num Object Obj = num; // Boxing Description : First, we declare a Value Type variable num of th...