Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Boxing

What is the real use of boxing and unboxing
in what situations will it be used.
Since all types are utlmately dereived from object..what is the need for boxing and unboxing.....help

SK
Friday, August 20, 2004

Deriving from object takes more memory than deriving from nothing ... an "int" for example does *not* derive from Object, and takes only 4 bytes of RAM.

"Boxing" creates an "object-which-contains-an-int", which is useful if you want to pas an int to something which expects an Object (for example, the ArrayList.Add method).

Caution: I haven't bothered to read the documentation, so I may be wrong about this.

Christopher Wells
Friday, August 20, 2004

Been good to me, Howard.

B F
Saturday, August 21, 2004

*  Recent Topics

*  Fog Creek Home