GeekInterview.com
Series: Subject: Topic:
Question: 73 of 348

what is boxing and unboxing?

Asked by: vHarish_06 | Member Since Sep-2007 | Asked on: Oct 3rd, 2007

View all questions by vHarish_06

Showing Answers 1 - 10 of 10 Answers
Sameer P.

Answered On : Oct 15th, 2007

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

Yes  2 Users have rated as useful.
  
Login to rate this answer.
sudhakar

Answered On : Oct 16th, 2007

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.

  
Login to rate this answer.
Gavaskar.s

Answered On : Nov 16th, 2007

Boxing: An value type will be convertered into object type.



Unboxing: Object type will be convertered into value type.

Yes  1 User has rated as useful.
  
Login to rate this answer.
parii

Answered On : Dec 10th, 2007

View all answers 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.

Yes  2 Users have rated as useful.
  
Login to rate this answer.
arshad236

Answered On : Jan 16th, 2008

View all answers by arshad236

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.

  
Login to rate this answer.
kirangiet

Answered On : Oct 23rd, 2009

View all answers by kirangiet

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) ;

Yes  2 Users have rated as useful.
  
Login to rate this answer.

Boxing: Boxing is process of converting valueType variable to Reference Type variable at runtime.
Unboxing: Unboxing is a process of converting reference type to value type variable at run time.
Value type is stored in Stacks
Reference type is stored in Heap
In C# :

int X=1;
Object Y;
int Z;

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

Yes  1 User has rated as useful.
  
Login to rate this answer.
santhoshkumark

Answered On : May 11th, 2011

View all answers by santhoshkumark

In Boxing value types are converted into reference. In unboxing reference types are converted into value.

  
Login to rate this answer.
Js

Answered On : Sep 12th, 2011

Boxing

Value Type -----> Reference Type

Un Boxing

Reference Type ------> Value Type

  
Login to rate this answer.
Aakash.ramya

Answered On : Jun 8th, 2012

View all answers by Aakash.ramya

Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type.
Unboxing is vice verse of boxing operation where the value is copied from the instance into appropriate storage location.

EX:-
Dim X As Integer
Dim Y As Object

X=10<--BOXING PROCESS-->
Y=X<--UNBOXING PROCESS-->

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.