foreach vs someList.ForEach(){}
There is one important, and useful, distinction between the two. Because .ForEach uses a for loop to iterate the collection, this is valid (edit: prior to .net 4.5 – the implementation changed and they both throw): someList.ForEach(x => { if(x.RemoveMe) someList.Remove(x); }); whereas foreach uses an enumerator, so this is not valid: foreach(var item in … Read more