.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

What is Boxing and unboxing ?

Posted By :Muthu     Posted Date :November 02, 2010    Points :10   Category :.NET Framework 
Boxing:
The conversion of a value type instance to an object, which implies that the instance will carry full type information at run time and will be allocated in the heap. The Microsoft intermediate language (MSIL) instruction set's box instruction converts a value type to an object by making a copy of the value type and embedding it in a newly allocated object.

Un-Boxing:
The conversion of an object instance to a value type.


You can also find related Interview Question to What is Boxing and unboxing ?  below: 

What is concept of Boxing and Unboxing ?

  
Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type. Boxing is a process in which object instances are created and copy values in to that instance. Unboxing is vice versa of boxing operation where the value is copied from the instance in to appropriate storage location. Below is sample code of boxing and unboxing where integer data type is converted in to object and then vice versa.
Dim x As Integer
Dim y As Object x = 10
' boxing process
y = x
' unboxing process
x = y (More...)

What is boxing and unboxing?

  
Converting a value type to reference type is called Boxing and Converting reference type of value type is Unboxing.

int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing (More...)

What is boxing and unboxing explain with example?

  
The example

class Test
{
static void Main() {
int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing
}
}

An int value can be converted to object and back again to int.
This example shows both boxing and unboxing. When a variable of a value type needs to be converted to a reference type, an object box is allocated to hold the value, and the value is copied into the box.

Unboxing is just the opposite. When an object box is cast back to its original value type, the value is copied out of the box and into the appropriate storage location. (More...)

What is boxing and unboxing?

  
Boxing is the process in which a object instances created and copying value type values to it. Unboxing is vice versa of boxing operation in which the value is copied from the instance into appropriate storage location. (More...)

What is concept of Boxing and Unboxing?

  
Boxing permits any value type to be implicitly converted to type object or to any interface type
implemented by value type. Boxing is a process in which object instances are created and copy
values in to that instance.

Unboxing is vice versa of boxing operation where the value is copied from the instance in to
appropriate storage location. (More...)

What is boxing and unboxing?

  
==Boxing
Value type to object type. Allocates memory on Heap.

==UnBoxing
Object type to value type. Allocates memory on Stack.
(More...)

Difference between Boxing and unboxing?

  
Boxing: Convert value type to reference type.
UnBoxing:Convert Reference type to value Type.
(More...)

Difference between Boxing and unboxing?

  
Boxing: Convert value type to reference type.
UnBoxing:Convert Reference type to value Type. (More...)

What is boxing and unboxing ?

  

he operation of Converting a Value Type to a Reference Type is called Boxing
Boxing Example:

int Var = 1; //This is a value type

Object Obj = Var; //Boxing we assign a value type into a reference

An unboxing conversion permits an explicit conversion from type object to any value-type

int Var = 1;

Object Obj = Var; //Boxing

int i = (int)Obj; //Unboxing (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend