using System.Collections.Generic;
public static void Main()
Dictionary<string,string> customers =
new Dictionary<string,string>()
{ "John", "John@emailprovider.com"},
{ "Jane", "Jane@Greystoke.org"},
{ "Eve", "Gilly@Eve.priv.uk"}
var Orders=customers.Select(x=>new Order{CustomerName=x.Key,CustomerEmail=x.Value}).ToArray();
.ForEach(o=> o.EmailBuyer())
.ForEach(o=> o.ProcessBilling())
.ForEach(o=> o.ProcessShipping());
public static class ExtensionForEach
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> enu, Action<T> action)
foreach (T item in enu) action(item);
public string CustomerName
public string CustomerEmail
private bool _billed=false;
Console.WriteLine("Emailing to " + this.CustomerName);
public void ProcessBilling()
Console.WriteLine("Billing to " + this.CustomerName );
public void ProcessShipping()
if(!Billed) throw new InvalidOperationException("Order can not be shipped if bill is not processed.");
Console.WriteLine("Shipping to " + this.CustomerName + " Bill Status:" + Billed.ToString());