There’s List(T).ForEach() that performs an action on each element of the list. However MSDN description doesn’t say anything about the order in which List elements will be traversed and I need to have them traversed strictly in order.
How can I achieve that with ForEach()?
List<T>.ForEachwill go in the same order as a normalforeachloop, which is also the natural order of the list.Yes, the documentation doesn’t state it – but it’s the obvious behaviour, and I think it’s pretty reasonable to rely on that not changing.
(Now
Parallel.ForEachis a different matter, of course.)