I want to create a method like this:
private static void AddOrAppend<K>(this Dictionary<K, MulticastDelegate> firstList, K key, MulticastDelegate newFunc)
{
if (!firstList.ContainsKey(key))
{
firstList.Add(key, newFunc);
}
else
{
firstList[key] += newFunc; // this line fails
}
}
But this fails because it says you can't add multicast delegates. Is there something I'm missing? I thought the delegate keyword was just shorthand for a class which inherits from MulticastDelegate.