The first data structure that meets this requirement is the array list, which is represented by the ArrayList class from the System.Collections namespace. You can use this class to store big collections of data, to which you can easily add new elements when necessary. Of course, you can also remove them, count items, and find an index of a particular value stored within the array list.
How can you do this? Let's take a look at the following code:
ArrayList arrayList = new ArrayList(); arrayList.Add(5); arrayList.AddRange(new int[] { 6, -7, 8 }); arrayList.AddRange(new object[] { "Marcin", "Mary" }); arrayList.Insert(5, 7.8);
In the first line, a new instance of the ArrayList class is created. Then, you use the Add, AddRange, and ...