firstList[key] = (MulticastDelegate)Delegate.Combine(firstList[key],newFunc);
with test:
var data = new Dictionary<int, MulticastDelegate>(); Action action1 = () => Console.WriteLine("abc"); Action action2 = () => Console.WriteLine("def"); data.AddOrAppend(1, action1); data.AddOrAppend(1, action2); data[1].DynamicInvoke();
(which is working)
But tbh, just use Delegate instead of MulticastDelegate ; it's pretty much a hangover from something that never worked. Or better; a specific type of delegate (possibly Action ).
source share