Re: When Overloading the Plus Operator, What are Valid Arguments Types?



Marc Gravell wrote:
Good analysis - one point, though:

"Change this to object o = failer + delegate..."

With the code as originally presented (MulticastDelegate), you'd need
to type the delegate:

o = failer + (EventHandler) delegate {...};

Oops, you're right, of course. Changing around things a little too enthusiastically to pin down the root cause.

Of course, a better option would be to declare something more specific
for the "del" argument - perhaps using the Action<...> or Func<...>
family to clarify the intent (EventHandler is fine too...).

Yes, using MulticastDelegate is pretty fishy -- I can't remember a single occasion where I had a need to explicitly declare that.

--
J.
.



Relevant Pages

  • Re: how to wrap your brain around delegates?
    ... A MulticastDelegate has a linked list of delegates, called an invocation ... consisting of one or more elements. ... When a multicast delegate is ...
    (borland.public.delphi.non-technical)
  • RE: C# code works but VB.NET shows a precompile error
    ... VB.NET is not my strongest side but I think you have to use the AddressOf operator: ... Dim newDelegate As MulticastDelegate ... > Protected Delegate Sub MulticastDelegate(ByVal sender As Object, ... > mEventHandler As EventHandler, ByVal loose As Boolean) ...
    (microsoft.public.dotnet.framework)
  • Events and delegates questions
    ... A delegate is a type-safe, ... A delegate declartion is C-sharp, f.e., public delegate void ... An event is simply a wrapper around a MulticastDelegate, the C-sharp ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Advanced use of delegates to automatically disconnect delegates from a set of events
    ... Delegate to form a new delegate. ... this MulticastDelegate that is equal to the specified delegate. ... void DisconnectAll; ... Where you would connect delegate del to event evt. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Multicast delegate checking for particular delegate
    ... >> I am surprised that a MulticastDelegate does not have a particular ... >> member function which checks if a particular delegate is in its ... It could be used to make sure that a delegate referencing the same member ... adds a delegate handler if that delegate handler does not already exist in ...
    (microsoft.public.dotnet.general)

Loading