Error: System.InvalidOperationException: Collection was modified; enumeration operation may not execute

Rashmi
Rashmi
1222 Points
22 Posts

Gettting following error:

Error: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
var targets = split.Panes.Where(p => p is DockManagerContentPaneState cp && cp.Id == id);
if (targets != null)
{
    foreach (var target in targets)
    {
        split.Panes.Remove(target);
    }                
    return true;
}
Views: 113
Total Answered: 0
Total Marked As Answer: 0
Posted On: 25-Sep-2025 23:23

Share:   fb twitter linkedin
Answers
 Log In to Chat