Possible Duplicate:
c#: how do I remove an Item inside IEnumerable
I have an Inumerable of Objects foo.
public IEnumerable<foo> listOfFoo{ get; set; }
Foo has Id and name lets say.
I want to pass an ID to a method and the method should remove the object with that ID from the IEnumerable and return it.
Whats the best way of doing it?
That’s not possible for any collection that implements
IEnumerable<foo>. If it is for example aList<foo>, then it’s possible to remove items for it, but if it is for example afoo[]it’s not possible to remove items.If you use a
List<foo>instead: