Boxing and unboxing is an important concept in C#. C# Type System contains three data types: Value Types (int, char, etc), Reference Types (object) and Pointer Types. Basically, it converts a Value Type to a Reference Type, and vice versa. Boxing and Unboxing enables a unified view of the type system in which a value of any type can be treated as an object.
|It convert value type into an object type.||It convert an object type into value type.|
|Boxing is an implicit conversion process.||Unboxing is the explicit conversion process.|
|Here, the value stored on the stack copied to the object stored on the heap memory.||Here, the object stored on the heap memory copied to the value stored on the stack .|
Value type of val is 2000 Object type of val is 2019
Value of o is 2019 Value of x is 2019
- C# | Boxing And Unboxing
- Difference between JSP and ASP
- Difference between LAN, MAN and WAN
- Difference between MAN and WAN
- What's difference between MMU and MPU?
- Difference between LAN and WAN
- Difference between CPU and GPU
- Difference between H.323 and SIP
- Difference Between BFS and DFS
- Difference between TDM and FDM
- Difference between MP4 and MP3
- What is the difference between GUI and CUI?
- Difference between PNG and GIF
- Difference Between SEO and SEM
- Difference between OOP and POP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.