I'm currently trying to remove the first element in an int array using objects in C#. I have just coded how to add an element to that start of the array and though it was just a case of changing a few things.
Here's the code for the addFirst() but i can't for the life of me figure out removeFirst()
Here's the code for the addFirst() but i can't for the life of me figure out removeFirst()
Code:
public void addFirst(int value)
{
if (isFull())
{
throw new Exception("List full");
}
else
{
for (int pos = size;pos > 0; pos-- )
{
values[pos] = values[pos - 1];
}
values[0] = value;
size++;
}
}
Comment