static void Main(string[] args) { Action <string> actionToPrint = str => Console.WriteLine(str); DelegatToPrint delegatToPrint = PrintToConsole1; delegatToPrint += PrintToConsole2; delegatToPrint += PrintToConsole1; delegatToPrint("hello World!"); //Multicast example. This way a lot of event handlers can be chained // This si sinchronous chaining - One after the other delegatToPrint.GetInvocationList(); //Array of Delegats DelegatToPrint funcNothig = DoNothing; DoNothing("Hello World!"); PrintStringByFunction(PrintToConsole1, "Heloo World!"); }
private static void PrintStringByFunction(DelegatToPrint delegatToPrint, string stringToPrint) { delegatToPrint(stringToPrint); }