boxing

  • Thread starter Thread starter ichor
  • Start date Start date
I

ichor

hi what is the use of boxing i understand that it is converting from value
types to reference types.. but why would i want to do that?

can anyone explain?
 
ichor said:
hi what is the use of boxing i understand that it is converting from value
types to reference types.. but why would i want to do that?

can anyone explain?

Sure. Take ArrayList, for example: that has an interface defined in
terms of "object" (a reference type). In order to store value types (eg
Int32) in an ArrayList, the values need to be boxed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top