Explain Boxing and unboxing in c#?

 Posted by CGN007 on 6/14/2012 | Category: C# Interview questions | Views: 2552 | Points: 40
Answer:

Boxing and unboxing in c#
Boxing is the process of converting a value type to the reference type.

int i = 1;

object obj = i; //boxing


Unboxing is the process of converting a reference type to value type.
object obj = 123;

i = (int)obj ; // unboxing


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response