[Solved] System.InvalidOperationException in my c# project
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 solved System.InvalidOperationException in my c# project