Gal Ratner
Gal Ratner is a Techie who lives and works in Los Angeles. Follow galratner on Twitter
How to use an anonymous delegate inside a lambda expression

If you have a collection of objects and you wish to invoke methods in the underlying objects you can use an anonymous delegate inside a lambda expression in the following form:

using System.Linq;

MyCollection.All((MyObject o)=> { o.MyMethod(); return true; });

This will run MyMethod on all of the objects in your collection.


Posted 6 Oct 2009 2:10 AM by Gal Ratner
Filed under:

Powered by Community Server (Non-Commercial Edition), by Telligent Systems