Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is boxing and unboxing ?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What describes a query?

985


Explain MVC model binders?

1122


Name the method that needs to be invoked on the dataadapter control to fill the generated dataset with data?

1038


What is the use of dispose method?

1078


i want to implement grid view value in paypal site. so how to create this code in asp.net with C#

1914


What are the asp.net security controls?

1209


What does ascx stand for?

992


how to transfer the file from client to server using asp.net

1170


What do you mean by marshalbyref?

1144


What is odata in web api?

1135


How does session work in asp net?

1112


What is difference between session and viewstate?

966


When you use Ajax controls in the ASP.NET application?

1085


How to prevent client side validation from the ASP.NET validation controls?

1159


What is a web api?

1097