I am trying to remove one item from the list until the list is empty. My code only successfully removes one item from the list and then cause an error. How do I fix this?
public void ReleaseAllAnimals()
{
int i = 0;
foreach (var value in _farmAnimals)
{
_farmAnimals.RemoveAt(i);
Console.WriteLine(value.Species());
i++;
}
}