You can do the repetition with for -loop
for (int i = depthCards.Count - 1; i >= 0; i--) { depthCards.RemoveAt(i); }
You can also use List.ForEach , which allows you to change the list in an iteration:
depthCardToUpdate.ForEach(dc => depthCardToUpdate.Remove(dc));
or if you just want to remove items provided use List.RemoveAll :
depthCardToUpdate.RemoveAll(dc => conditionHere);
Rango
source share