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 / kumaresh

BOXING: Converting value type to referenc type.
Here we go with an example,

ArrayList instance = new ArrayList()
//In the above line of code,ArrayList is a reference
type.Add some items to the arraylist. For example,

instance.Add(1);
instance.Add(100);
instance.Add(3);
//3 items added to the arraylist.
//Integer valuee 3 is value type.Adding 3 to the reference
type(here it's arraylist) is boxing.
i.e., Converting value type to referenc type.

UNBOXING:Converting Reference type to value type.
Below is an example, retrives the items from the
arraylist.

foreach (int item in arrayList)
Console.WriteLine(item);

Here arraylist(referenec type) will have 3 values in the
list, which we added above.
Adding this arraylist items to an int variable[here int
variable is "item"] is unboxing.
i.e.,converting the reference type to value type.

Hope you would have understood.
Thanks

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List some of the important session state modes of asp.net.

945


We Only Know The Total Number Of Feet In The Farmyard. Write A Program that will compute the total number of rabbits and chickens in the farmyard. Assume number of feet in the farmyard are 40. how many rabbits and chickens are?

831


What are the different types of proxy patterns?

1086


What is intrinsic objects in asp.net?

1170


Distinguish between Server-side and Client-side code with its functionality?

1078


Can we use a static function with a non-static variable?

931


What does ascx stand for?

893


How can we apply themes to an asp.net application?

991


Explain diff. Betn dataset and recordset?

957


Less than one page, how many windows will you be able to maintain?

940


If we remove web.config or machine.config from the application then, is this application will works?

967


code for "For every 5days system has to create 1text file with the corresponding date and it has to store in c-drive" by using web applications

1799


What is Cookies Less Session?

993


Explain how asp.net different from asp?

1058


How asynchronous call can be implemented using delegates?

961