Edge
4.5
Available
Beginning in .NET Framework 4.5, a xref:System.Collections.Generic.List`1.ForEach(System.Action{`0}) enumerator will throw an xref:System.InvalidOperationException?displayProperty=name exception if an element in the calling collection is modified. Previously, this would not throw an exception but could lead to race conditions.
- Quirked
- Build-time break
Ideally, code should be fixed to not modify lists while enumerating their elements because that is never a safe operation. To revert to the previous behavior, though, an app may target .NET Framework 4.0.
M:System.Collections.Generic.List`1.ForEach(System.Action{`0})
Core