I have an array of strings.
string[] array = new string[] { "0", "1", "2", "3", "4", "5", "6" };
I would like to remove a string from the array above using a variable removeIndex, let's say it is equal to 3.
int removeIndex = 3;
I now have to rearrange my array so that all the strings are moved back by one index.
int end = array.Length - 1;
for (int i = removeIndex; i < end; ++i)
{
array[i] = array[i + 1];
}
The last index is now null.
array[end] = null;
Is this the best approach to moving all objects back one space in an array? What would you change if not?