FYI, ArrayList is considered by many to be evil. As Kevin said, we would be better off List <People>.
A list is what is called a general. Google has “scored”, “boxing” and “generics” to better understand why.
back to the original question: The size of the array must be declared when creating the instance, i.e. People [] people = new people [5];
this creates 5 empty cells in the array so you can access the cells using the index, that is [0]
ArrayList or List <T> when an instance using the default constructor has no cells, i.e. List <People> people = new List <People> ();
people [0] do not exist at this point.
use people.Add (new people ("first", "last")); to add a new cell to the list. now index [0] is valid, but [1] is still invalid because there is only one cell.
List i.e. ArrayList or List can be dynamically incremented with .Add (). After adding to the list, you can reference them using the index [i], but you cannot use a substring to add them.
source share