I have been reading a bit about delegates in depth, it is confusing that a delegate with one method could be different than a multicast delegate. However, via reflection, you can see plainly that even with only a single method, a delegate is indeed deriving from MulticastDelegate
, and not immediately deriving from a Delegate
object.
class Program
{
public delegate void MyDelegate();
static void SomeMethod()
{
}
static void Main(string[] args)
{
MyDelegate del = null;
del = new MyDelegate(SomeMethod);
Console.WriteLine(del.GetType().BaseType.Name);
Console.ReadKey();
}
}
Output:MulticastDelegate
I realize that a MulticastDelegate
contains an invocation list of Delegate
objects. I am wondering if it is possible to create a single Delegate
directly and if there would be any advantage to doing so, other than calling GetInvocationList()
and extracting the Delegate
objects individually.