Q:

What do you mean by boxing and unboxing in C#?

0

What do you mean by boxing and unboxing in C#?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Boxing: This is the process of converting from value type to reference type.

Example
int i = 67; // i is a value type
object o = i; // i is boxed
System.Console.WriteLine(i.ToString()); // i is boxed

UnBoxing: It’s the process of converting reference type to value type.
System.Collections.ArrayList list = new System.Collections.ArrayList(); // list is a reference type
int n = 67; // n is a value type
list.Add(n); // n is boxed
n = (int)list[0]; // list[0] is unboxed

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Top 100 C# interview questions and answers 2022

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Can “this” be used within a static method?... >>
<< What is Nullable Type in C#?...