Monday, November 29, 2010

Linq does not support Remove

I tried to remove an item from a list
obj.Remove(t => t.Name == "abc");
The first thing was the intellisense was not supporting
Cannot convert lambda expression to type because it is not a delegate type
This error message is misleading.

I've to do a find and get the object
and then i get
obj.Find(t => t.Name == "abc");
and then remove it
conversely I can do
obj.RemoveAll(t => t.Name == "abc");
Remove means remove the first entry, i don't understand why Linq is not supporting Remove and I dont see any good documentation explaining the same