For some reason i dont understand one item wont remove from my list.
int totalBarIndex = (ChartBars.ToIndex);
var listP = new List<int>() {194,389,584,779,974,1169,1364,1559,1754,1949,2144 ,2339,2729,3119,3509,3899,4289,4679,5069};
foreach(var list in listP)
{
if(list > totalBarIndex)
{
listP.Remove(194);
listP.Remove(389);
listP.Remove(584);
listP.Remove(779);
listP.Remove(974);
listP.Remove(1169);
listP.Remove(1364);
listP.Remove(1559);
listP.Remove(1754);
listP.Remove(1949);
listP.Remove(2144);
listP.Remove(2339);
listP.Remove(2729);
listP.Remove(3119);
listP.Remove(3509);
listP.Remove(3899);
listP.Remove(4289);
listP.Remove(4679);
listP.Remove(5069);
}
}
I194
I389
I584
I779
I974
I1169
I1364
I1559
I1754
Indicator 'MyCustomIndicator6': Error on calling 'OnRender' method on bar 1754: Collection was modified; enumeration operation may not execute.
totalBarIndex = 1754
Often it will return the number just after the value of totalBarIndex in this case 1949 and will not remove it from the list.
Any idea why?
TY

Comment