Tutorial by Examples

public class Customer { public void SendEmail() { // Sending email code here } } List<Customer> customers = new List<Customer>(); customers.Add(new Customer()); customers.Add(new Customer()); customers.ForEach(c => c.SendEmail());
ForEach() is defined on the List<T> class, but not on IQueryable<T> or IEnumerable<T>. You have two choices in those cases: ToList first The enumeration (or query) will be evaluated, copying the results into a new list or calling the database. The method is then called on each it...

Page 1 of 1