What is boxing and unboxing ?
Answers were Sorted based on User's Feedback
Answer / narayansahu
boxing is conversion from value type to object(reference)
type.Actually the copy of value type copied from stack to
heap memory.
unboxing is reverse of it.from heap memory back to stack
memory.
| Is This Answer Correct ? | 70 Yes | 4 No |
Answer / satyambabu
BOXING
? Boxing is an implicit conversion of a value type to
the type object
UNBOXING
? Unboxing is an explicit conversion from the type
object to a value type
| Is This Answer Correct ? | 28 Yes | 4 No |
Answer / narayansahu
Boxing and Un-boxing
Boxing allows value types to be implicitly treated like
objects.
Dim i As Integer = 5
i.ToString() ' i --> object --->object.tostring
OR
Dim i As Integer = 5
Dim obj As Object = i ' implicit boxing
obj.ToString()
OR you can do it explicitly
Dim obj As Object = CType(i, Object) ' un-necessary
explicit boxing
On the other hand, un-boxing is an explicit conversion from
object type to value type.
Dim i As Integer = 5
Dim obj As Object = i ' implicit boxing
Dim j As Integer = CType(obj, Integer) ' explicit un-boxing
? Boxing and Un-boxing is the transformation between
value type and object type while casting just transforms
the apparent (reference) type of objects.
? Value types are stored at the stack and objects are
stored at the heap.
Boxing takes a copy of value types from the stack to the
heap while un-boxing takes value types back to the stack.
On the other hand, casting does not physically move or
operate on an object. Casting merely changes the way
objects are treated in a program by altering their
reference type.
| Is This Answer Correct ? | 23 Yes | 6 No |
Answer / manish singh(amalga fusion)
boxing is used to convert value type to reference type.
unboxing is used to convet reference type to value type.
| Is This Answer Correct ? | 21 Yes | 4 No |
Answer / rahultripathi
There is two type datatype available Value and reference
type . value are stored in stack and reference type used
in heap . when we copy data from stack memmory to heap it
call Boxing .
Int32 x = 10; object o = x ; // Implicit
boxing
Int32 y = 10;
unboxing : copy data from heap memory to stack called
unboxing
object obj = (object) y; // Explicit Boxing
Rahul Tripathi
raultripathi@myway.com
| Is This Answer Correct ? | 18 Yes | 2 No |
Answer / sivasaravanan
Boxing;
Encapsulating a copy of value in an object.
UnBoxing:
Vice-versa
| Is This Answer Correct ? | 14 Yes | 2 No |
Answer / subhrajit maity
in Csharp language boxing is used to convert value type to
object (reference type).
value to reference.
In this time value copied from stack to heap.
For un boxing convert reference to value.
Value copied from heap to stack
| Is This Answer Correct ? | 8 Yes | 3 No |
How many classes can a single .NET DLL contain?
Which method is used to force all the validation controls to run?
Explain the advantages of asp.net.
What is a Cookie? Where is it used in ASP.NET?
what are httphandlers and httpmodules.and their differences.
what is cross page posting
hi i have a problem regarding to datagrid in aspdotnet.i have a datagrid in my application.i have to place add,edit,delete buttons or links what ever it may be. now the problem is if i click on add button then the page has to redirected to another form called "xyz.aspx" and if i click on edit button the page has to redirected to another form called "abc.aspx".i am phasing the problem that if where ever i click on the datagrid the cursor goes to gv1_SelectedIndexChanged event.please tell me the solution about the code.
Define repository pattern in asp.net mvc? : asp.net mvc
How do you declare delegates and are delegates and events one and the same and explain how do you declare delegates and invoke them ?
I have an external link in my application say www.xyztest.com. Today this site works on http protocal. Tommorow it may run on https. So i cant hardcore the protocal in the site. When a user clicks on the link how can i know if the external site works on http or https and takes him to that place?
Which of the following hosts Can't be used to create .net Application? a) IIS b) Internet Explorer c) ASP.Net d) Windows Shell Which one is correct?
What is the basic purpose of the required field validator? How can you use a required field validator to check that the user changes the initial value of a text box? a listbox?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)