public static void Main(string[] args) { // Wiring up the delegate pipeline to event handler. DoTheWorkHandler del = new DoTheWorkHandler(DoTheWork); DoTheWorkHandler del1 = new DoTheWorkHandler(DoOtherWork); DoTheWorkHandler del2 = new DoTheWorkHandler(DoYetMoreWork); // order matters on multicast delegate del += del1 + del2; // FYI: the last delegate return value is the one that is used. They are not 'accumulated'. //int finalHours = del("Chris", WorkType.Shopping); //Console.WriteLine($"finalHours: {finalHours}"); Worker work = new Worker(); work.DoWork("Monday", WorkType.Shopping); Console.Read(); // Exit run }
// Invoke the delegate static void DoWork(DoTheWorkHandler del) => del("Chris", WorkType.Work);