I have a LinkedList, where Entry has a member called id. I want to remove the Entry from the list where id matches a search value. What's the best way to do this? I don't want to use Remove(), because Entry.Equals will compare other members, and I only want to match on id. I'm hoping to do something kind of like this:
entries.RemoveWhereTrue(e => e.id == searchId);
edit: Can someone re-open this question for me? It's NOT a duplicate - the question it's supposed to be a duplicate of is about the List class. List.RemoveAll won't work - that's part of the List class.
list.Remove(list.First(e => e.id == searchId));
Here's a simple solution:
list.Remove(list.First((node) => node.id == searchId));
Just use the Where extension method. You will get a new list (IIRC).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With