- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between Boxing and Unboxing in C#
Boxing convert value type to an object type whereas unboxing converts object type to the value type.
Let us see the difference between Boxing and Unboxing in C#.
Storage
In boxing, the value stored on the stack is copied to the object stored on heap memory, whereas unboxing is the opposite.
In Unboxing, the object's value stored on the heap memory is copied to the value type stored on stack.
Conversion
Unboxing has explicit conversion whereas boxing has implicit conversion.
Example
int a = 10; object obj = a; // boxing int b = (int) ob; // unboxing
Advertisements