Instead of using an array, you can use an object List<>in C #.
List<int> integerList = new List<int>();
To iterate over the elements contained in a list, use the operator foreach:
foreach(int i in integerList)
{
}
You can add items to the list object with Add()and functions Remove().
for(int i = 0; i < 10; i++)
{
integerList.Add(i);
}
integerList.Remove(6);
integerList.Remove(7);
You can convert List<T>to an array using the function ToArray():
int[] integerArray = integerList.ToArray();
Here is the documentation on the site List<>.
source
share