Answers for "collection was modified enumeration may not execute"

C#
0

Collection was modified; enumeration operation might not execute. datatable c#

using CentroidsList = System.Collection.Generic.List<...>; //put the type of the element of newSpectrum.PeakCentroids

//...

CentroidsList list = new CentroidsList();
foreach (var element in newSpectrum.PeakCentroids)
   if (SomeCondition(element))
       list.Add(element);
foreach (var element in list)
   newSpectrum.PeakCentroids.Remove(element);
Posted by: Guest on October-07-2020

Code answers related to "collection was modified enumeration may not execute"

C# Answers by Framework

Browse Popular Code Answers by Language