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.
 
Back
Top