OJ’s rants What would OJ do?

25Mar/097

A Quirk in List.Find()

Earlier today I was having a chat with a friend of mine, who lives in Vancouver, about finding items that are stored in generic Lists. He flicked me a code snippet that looked something like this:

List<foo> list = new List</foo><foo>();
// .. do some stuff
Foo f = list.Find(delegate(Foo f) { return foo.Name == "Bar"; });
</foo>

Straight away I fired back with an update to the code which used lambda expressions instead, as I'm a fan of how concise they are ;)