|
- c# - Why doesnt IEnumerable lt;T gt; have FindAll or RemoveAll methods . . .
Calling it RemoveAll does NOT make sense since no IEnumerable<T> method implementation should modify a collection So in my case I sometimes use a custom extension method I call Nil static IEnumerable<T> Nil<T>(this IEnumerable<T> self) { yield break; } As for FindAll as Marc already pointed out is simply called Where
- c# - Remove an item from an IEnumerable lt;T gt; collection - Stack Overflow
Try turning the IEnumerable into a List From this point on you will be able to use List 's Remove method to remove items To pass it as a param to the Remove method using Linq you can get the item by the following methods: users Single(x => x userId == 1123) users First(x => x userId == 1123) The code is as follows: users = users ToList(); Get IEnumerable as List users Remove(users First(x
- c# - Remove items from IEnumerable lt;T gt; - Stack Overflow
There is no Remove method on IEnumerable<T>, because it is not meant to be modifiable The Except method doesn't modify the original collection: it returns a new collection that doesn't contain the excluded items: var notExcluded = allObjects Except(objectsToExcept); See Except on MSDN
- c# - How to remove items in IEnumerable lt;MyClass gt;? - Stack Overflow
How do I remove items from a IEnumerable that match specific criteria? RemoveAll() does not apply
- c# - Removing item from list with RemoveAll - Stack Overflow
Your code is taking an IEnumerable, copying all of its elements into a list and then removing items from that copy The source IEnumerable is not modified Try this: var list = ChartAttributes ToList(); list RemoveAll(a => a AttributeValue Contains("PILOT")); ChartAttributes = list; EDIT Actually a better way, without needing to call ToList: ChartAttributes = ChartAttributes Where(a => !a
- c# - Most efficient way to remove multiple items from a IList lt;T . . .
What is the most efficient way to remove multiple items from an IList<T> object Suppose I have an IEnumerable<T> of all the items I want to remove, in the same order of occurrence that
- Sort or RemoveAll first on an IEnumerable that needs both?
Just as a small FYI: your contrived example won't compile since Sort and RemoveAll are both List<T> -specific and not available to any arbitrary IEnumerable<T> (nor should they be, since IEnumerable<T> is a read-only interface)
- c# - List (T) RemoveAll () not working as intended. . . ? - Stack Overflow
Instead of RemoveAll (), you could try using IEnumerable's filter where you would say something like : var filteredList = lst Where(item => IsExisting(item Id)) This makes the code a little more easier to read and focusses on the objective of the task at hand, rather than how to look at implementing it
|
|
|