I want to remove multiple indexes from a linq list, I am using the following code:
slidePart
.Slide
.Descendants<DocumentFormat.OpenXml.Presentation.Picture>()
.ToList()
.ForEach(pic => pic.Remove());
There are 3 elements in the List and now what I want is to select only the 1st and 3rd element then execute ForEach to remove them.
[Edit]
The Problem is also that Indexes are dynamic.
If your list (toRemove) is large, you may reduce the search time (of Contains) from O(n) to O(1) by changing the declaration of
toRemovea little bit