An ArrayList
only contain references to the objects, not the objects themselves. All references are the same size, so the problem doesn't exist.
The internal type of the reference is surely object
.
For generic arrays of value types, the actual value is stored in the array and the size of the element is used as you describe. If you put a value type in an ArrayList
it will be boxed into an object and the reference to that object is stored in the ArrayList
.