If I use:
var strings = new List { \"sample\" };
foreach (string s in strings)
{
Console.WriteLine(s);
strings.Add(s + \"!\");
}
We know about this issue, it was an oversight when it was originally written. Unfortunately, we can't change it because it would now prevent this previously working code from running:
var list = new List();
list.Add("Foo");
list.Add("Bar");
list.ForEach((item) =>
{
if(item=="Foo")
list.Remove(item);
});
The usefulness of this method itself is questionable as Eric Lippert pointed out, so we didn't include it for .NET for Metro style apps (ie Windows 8 apps).
David Kean (BCL Team)