[Solved] System.InvalidOperationException in my c# project

[ad_1]

Don’t remove elements while iterating over the collection with a foreach.

Also, I’d recommend using List<T> rather than ArrayList.

An easier way to solve the task at hand is to simply do:

public static void Remove(List<Account> L, int accnb) => 
                            L.RemoveAll(obj => obj.AccN == accnb);

0

[ad_2]

solved System.InvalidOperationException in my c# project