1. Using a generic delegate
=> foreach (Customer c in Customers.Where(new Func<Customer, bool>(MatchName)) {}

bool MatchName(Customer c) { return c.CustomerID.StartsWith("L"); }

2. Using an anonymous delegate
=> foreach (Customer c in Customers.Where(delegate(Customer c) { return c.CustomerID.StartsWith("L")}) {}

3. Using a lambda expression
=> foreach (Customer c in Customers.Where(c => c.CustomerID.StartsWith("L"))) {}

4. Using as LINQ query expression
=> var query = from c in Customers where c.CustomerID.StartsWith("L") orderby c.CustomerID select c;

foreach (Customer c in query) { }

+ Recent posts