C# › Delegates, Events & Lambdas
What are multicast delegates, and in what order do their subscribed methods get invoked?
IntermediateAnswer
A delegate can hold references to MULTIPLE methods simultaneously (added via +=), forming an invocation LIST — calling the delegate invokes every subscribed method IN THE ORDER they were added, one after another, sequentially on the same thread.
Action greetings = null;
greetings += () => Console.WriteLine("Hello");
greetings += () => Console.WriteLine("Hi");
greetings += () => Console.WriteLine("Hey");
greetings?.Invoke(); // prints Hello, Hi, Hey in that orderReal-world example Allowing multiple independent parts of an application to subscribe to and react to the same event, like a logging system and a UI update both reacting to OnDataChanged.