Sorry, my english is not well.
Help me! I have a List<int> with its items are indexes of items in EditableRootList.
I do:
for(int i = 0; i < List.Count; i++)
{
EditableRootList.RemoveAt(i)
}
But I catch an exception: out of arrange. Because when remove a item in EditableRootList, index is changed.
Sorry, Above code is incorrect
It is here:
for(int i = 0; i < List.Count; i++)
{
EditableRootList.RemoveAt(List[ i ])
}
Begin with the largest index item, then the next smallest, next smallest...
Also, your code removes ALL the items. You have a list of integers like {2,11,24,26,49}, right? And you only want to remove items 2, 11, 24, 26, and 49 from the EditableRootList, right?
I don't know C# very well, but I'm going to assume that the way you refer to an item in a list by its listindex is "List(Index).Value". If that were true, your code should look more like this:
for(int i = List.Count-1; i > -1; i--)
{
EditableRootList.RemoveAt(List(i).Value)
}
Copyright (c) Marimer LLC