Boxing and Unboxing : A Quick Overview



Difference between Boxing and Unboxing in c#

Boxing 

Boxing is an implicit conversion process. It converts value type (int, char, etc.) into reference type (object).

int res= 10; // 23 will assigned to res variable
Object Ob = res; // Boxing

Unboxing

Unboxing is an explicit conversion process. It converts reference type (object) to value type (int, char, etc.).

int res= 10; // value type is int and assigned value 10
Object Ob = res; // Boxing
int num = (int)Ob; // Unboxing

0 Comment's

Comment Form

Submit Comment