GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  ASP.NET
Go To First  |  Previous Question  |  Next Question 
 ASP.NET  |  Question 141 of 164    Print  
what is boxing and unboxing?

  
Total Answers and Comments: 6 Last Update: October 23, 2009     Asked by: vHarish_06 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: parii
 
Boxing is what happens when a value-type object is assigned to a reference-type variable.
Unboxing is what happens when a reference-type variable is assigned to a value-type variable.

Above answer was rated as good by the following members:
surendra_sahu786, surendrabalamali
October 15, 2007 06:32:44   #1  
Sameer P.        

RE: what is boxing and unboxing?
Boxing is converting a value type to reference type

Unboxing is an explicit operation.

Eg.

In C# :

int X 1;
Object Y;
int Z;

Y X; -------------> This is BOXING
Z (int)Y; ----------------> This is UNBOXING

 
Is this answer useful? Yes | No
October 16, 2007 07:21:58   #2  
sudhakar        

RE: what is boxing and unboxing?
Boxing: Boxing is process of converting valueType variable to Referance Type veriable at runtime.
Unboxing: Unboxing is a process of converting referance type to value type variable at run time.

 
Is this answer useful? Yes | No
November 16, 2007 05:48:10   #3  
Gavaskar.s        

RE: what is boxing and unboxing?
Boxing: An value type will be convertered into object type.



Unboxing: Object type will be convertered into value type.

 
Is this answer useful? Yes | No
December 10, 2007 02:10:46   #4  
parii Member Since: December 2007   Contribution: 30    

RE: what is boxing and unboxing?
Boxing is what happens when a value-type object is assigned to a reference-type variable.
Unboxing is what happens when a reference-type variable is assigned to a value-type variable.

 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
January 16, 2008 15:04:11   #5  
arshad236 Member Since: January 2008   Contribution: 1    

RE: what is boxing and unboxing?
Boxing is a process of converting value type into reference type while unboxing is vice versa

What happened in backend.

Value type is stored in Stacks
Reference type is stored in Heap

So boxing.

Values shifted Stacks to Heap and vice versa.

 
Is this answer useful? Yes | No
October 23, 2009 02:11:04   #6  
kirangiet Member Since: June 2009   Contribution: 24    

RE: what is boxing and unboxing?
Boxing: Converting Value Type into Reference Type

Example:

int i 10;

string str Convert.ToString(i);


Unboxing: Converting Reference Type into Value Type

Example:

string str "10";

int i Convert.ToInt16(str) ;


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape