boxing means converting value type to reference type and
unboxing means converting reference type to value type.why
we need boxing and unboxing?

Answer Posted / uday

We use boxing and un-boxing when we assign a value to an
object and vice-versa.
Ex:

Int i=10;
Object o=i //this is boxing
int j=(int)o; //this is unboxing

When u say boxing, an object box is allocated and then the
value is copied to that box.
When u unbox, the value is copied out of the object box and
copied into storage location.

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does c# support c type macros?

556


How can you read 3rd line from a text file?

528


What is xml serialization and deserialization in c#?

478


What is eager and lazy loading in c#?

463


What is the difference between ref & out parameters in c#?

456






Describe the difference between inline and code behind - which is best?

553


What is the property of class?

577


Explain the process of Serialization?

546


What are native functions?

470


What is difference between association, aggregation and inheritance relationships?

492


What is sqladapter c#?

528


Do we get an error while executing the “finally” block in c#?

505


Can we override static class in c#?

477


Why delegates are required?

535


What is the default boolean value in c#?

507