I think the answer is NO? If there isn't, why do we have separated Delegate
and MulticastDelegate
classes? Maybe it's again because of "some other .NET languages"?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
System.MuticastDelegate is derived from System.Delegate. Each level within the delegate hierarchy provides a different set of services. System.Delegate is a container of the data for what method to call on a particular object. With System.MulticastDelegate comes the additional capability of not only invoking a method on a single object, but on a collections of objects. This enables multiple subscribers to an event.
Not sure, i have answered your question.
No, there isn't, because all delegates must naturally be able to be
Delegate.Combine
ed. Delegate is there simply to wrap the non-multicasting functionality into a base class.No, the CLR does not allow that.
I recall something that they wanted to expose
Delegate
directly, but that was never needed.EDIT: I thought this was part of ECMA 335, but I can't see it in there anywhere.
You can't create such a delegate type in C#, but you can in IL:
The C# compiler has no problems using such a delegate:
But the CLR does when it tries to load it:
Basically the Delegate/MulticastDelegate separation is an historical accident. I believe that early alpha/beta versions did make the distinction, but it proved too confusing and generally not useful - so now every delegate derives from MulticastDelegate.
(Interestingly, the C# specification only mentions MulticastDelegate once, in the list of types which can't be used as generic constraints.)