8.26.2012

Difference between Boxing and Unboxing in C#

Difference between Boxing and Unboxing in C#
S.No Boxing Unboxing
1
Meaning:
Boxing is the process of converting a value type to the reference type.
Meaning:
Unboxing is the process of converting a reference type to value type.
2
Type of Conversion:
Implicit Conversion
Type of Conversion:
Explicit Conversion
3
Example:
int i = 1;
object obj = i; //boxing
Example:
object obj = 123;
i = (int)obj ; // unboxing

2 comments:

  1. it is not sufficent diffrence more difference in tabular form

    ReplyDelete
    Replies
    1. Check this one

      https://technicalinterviewbiz.blogspot.com/2019/10/difference-between-constant-and-read.html

      Delete