If your collection type is List<stuff> , then the best approach is probably the following:
prods.RemoveAll(s => s.ID == 1)
This is only one pass (iteration) over the list, so it should be more efficient than other methods.
If your type is more typical of ICollection<T> , this can help write a short extension method if you care about performance. If not, then you will probably be able to use LINQ (calling Where or Single ).
Noldorin Jul 19 '10 at 7:39 2010-07-19 07:39
source share