public static void Execute() { var actor = new Doer(); // doesn't matter how we declare the delegate method... DoSomethingWithANumber thingToDo = i => Console.WriteLine(i * 2); actor.ActUponANumber(5, thingToDo); actor.ActUponANumber(5, actor.DoSomethingSpecial); actor.ActUponANumber(5, i => Console.WriteLine(new string('*', i))); }
public static void Execute() { var actor = new Doer(); // http://msdn.microsoft.com/en-us/library/system.action(v=vs.110).aspx Action action = actor.DoSomething; action(); // http://msdn.microsoft.com/en-us/library/018hxwa8(v=vs.110).aspx Action<int> anotherAction = actor.DoSomethingSpecial; anotherAction += Console.WriteLine; anotherAction(6); }