开发者

C# System.Delegate.Combine

I have a bit of confusion regarding static Combine( ) provided in System.Delegate( )

This method returns a System.Delegate type and its purpose is to combine invocation lists of multiple delegates.

But if a delegate is supposed to refer to 开发者_Python百科a single method, and a multicast delegate is supposed to hold reference to multiple methods, then how is the return type of Combine justified as just a System.Delegate?

I think I am missing something here.

Can someone please help.

Thanks.


All delegates have the capability of being multicast. Consider Delegate.GetInvocationList.


This is a bit of a shot in the dark, but Multicast Delegates inherit from Delegates... so while it returns an object that is of the Type Delegate, you may be able to cast it to a multicast delegate....


System.Delegate is abstract, so there is never an instance of System.Delegate returned, just instances of concrete types () derived from System.MulticastDelegate. To my knowledge there is no type that is a Delegate that can only hold a reference to one method.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜