Reputation: 63
I'm trying to remove an object from a list, First I need to get all the entries in it with the id == 0(for now) and then remove the first entry. At the moment I'm trying:
coursework.Where( x => x.Id == moduleList.SelectedIndex).remove(coursework[testList.SelectedIndex]) // Doesnt exist in this context
But that doesn't work and I've tried many things but can never find anything that works.
Upvotes: 0
Views: 591
Reputation: 887275
.Where()
returns an IEnumerable<T>
containing matched items.
It cannot be used to modify the original list.
Instead, you should call .RemoveAll()
.
Upvotes: 1