I'm required to use an array for this specific project. Currently there are names saved at each index in array[10]
. What I want to do is if I delete array[1]
, all data will move up one index freeing up or making array[10] = null
. Currently, I'm doing it with
public void Delete(int a)
{
do
{
array[a] = array[a + 1];
}
while (array[a + 1] != null);
}
yet when I try to retrieve the array with
for (int h = 0; h < array.Length; h++)
{
Console.WriteLine(array[h]);
}
there would be a gap in which 1, 3, 4...
Is there a better way to go about it?