Having the following for loop:
for (var i = list.Count - 1; i >= list.OrderBy(x => x).First(); i--)
if (list.Contains(i))
list.RemoveAt(i);
- Does list.Count() get checked every iteration?
- Does list.OrderBy(x => x.Key).First() get executed every iteration
- Should this be thread safe? because of adding/removing?
What I'm driving at is that, during the for loop execution items may be added to the list (elsewhere-in a different method)