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

Answers were Sorted based on User's Feedback



boxing means converting value type to reference type and unboxing means converting reference type t..

Answer / 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

boxing means converting value type to reference type and unboxing means converting reference type t..

Answer / madhu maaydi

some times super class ref is may not available to subclass objects at that time we may go for umboxing, data in the web application travers in the net throuw objects only but not through variables at that time we need to type cast it into equalent obecjt at this time we go for boxing and auto boximg....

Is This Answer Correct ?    0 Yes 0 No

boxing means converting value type to reference type and unboxing means converting reference type t..

Answer / deepak

actually we need boxing and unboxing to keep more than one type of value type of variables in a common reference type of collection.. so that you can do the common operation in a loop or anywhere else.. by unboxing one by one.. also you can pass that collection to any method.. so you dont need to make many overloaded method for every type of value type..

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Sharp Interview Questions

What is the advantage of constructor in c#?

0 Answers  


what is main function of alternate teamplate of datalist?

0 Answers  


What is string programming language?

0 Answers  


What is a console operator?

0 Answers  


the selected inf of other combobox?How do you achieve it?

1 Answers   CTS, Microsoft,






Why main method is static in c#?

0 Answers  


What is an assembly qualified name? Is it a filename? How is it different?

0 Answers  


Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

2 Answers   Siebel Systems,


What is the implicit name and type of the parameter that gets passed into the class set method?

0 Answers  


What is garbage collector and where should you use in .NET?

0 Answers   Siebel,


What is the predicate of a sentence?

0 Answers  


What’s the difference between System.String and System.Text.StringBuilder classes with example

2 Answers  


Categories