I hope the .NET developers are enjoying with C# 3.0 lambda expressions. This is one of the easiest way for removing items from the generic list object based on a condition.

_sessionList.RemoveAll(x => x.MarkforRemoval == true);

The above code removes all the items marked for removal. This also avoid the error “Collection was modified; enumeration operation may not execute” if you are checking the conditions in the foreach loop and removing it.

Quick snippet, hopefully useful.


 
Wednesday, October 07, 2009 5:11:51 PM (India Standard Time, UTC+05:30)
hey, how does this work in sql servr 2008?
Stewart John
Comments are closed.