I'm working on a class project and here is what I have so far. I know the code returns true when it finds a match but I want it to keep looping until no more instances are found.
I've looked at numerous sites on for/while loops but I can't seem to get the syntax correct and/or it doesn't work when applying the logic.
public bool Remove(T toRemove)
{
for (int i = 0; i < count; i++)
{
if (items[i].Equals(toRemove))
{
int removeIndex = i;
for (int j = removeIndex; j < count - 1; j++)
{
items[j] = items[j + 1];
}
return true;
}
}
return false;
}