Array of an unknown length in C#

Arrays must be assigned a length. To allow for any number of elements, use the List class.

For example:

List<int> myInts = new List<int>();
myInts.Add(5);
myInts.Add(10);
myInts.Add(11);
myInts.Count // = 3

Leave a Comment