Solution 1 would be correct if it explained
Capacity
. It does not mean that you cannot add more items then
Capacity
. You can. But all you need is to read the documentation:
Capacity is always greater than or equal to Count. If Count exceeds Capacity while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements.
More importantly:
you should never use this list type. It is rendered obsolete as early as of the .NET v.2.0, when generics were introduces. You should always use generic collection types from
System.Collections.Generic
(and also specialized collections). For a list, use
System.Collections.Generic.List<>
:
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx[
^].
Non-generic types are much worse because they require potentially dangerous type cast. You never need them. However, these classes were not marked with
[Obsolete]
attribute, just because there is nothing wrong with using them in legacy code. In new development, there is absolutely no reason to use them.
—SA