Rubén Aroca Rubén Aroca - 6 months ago 5x Question

Set a fixed size ArrayList

someone knows if it's possible create a fixed size ArrayList? Or I have to use necessarily an array?

I try with this

Dim array As ArrayList

array = New ArrayList(10)


array.Capacity = 10

But I can add more than 10 items, and it doesn 't show me any kind of error how I expected.



Just use an Array this size will not change unless you explicitly code it to.

Dim myArray(9) As String 'or whatever object you need Integer, etc.

Note that specifying 9 will create 0-9 i.e. 10 items in your array

(ArrayLists are bad in many many ways so don't use them)