Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would like to point out that comparing this incident to the 'int' case is probably inherently wrong since even though 'int' is atomic, it is a value type.</p> <p>But I think we've solved the case:</p> <blockquote> <p>Combining operations, such as Combine and Remove, do not alter existing delegates. Instead, such an operation returns a new delegate that contains the results of the operation, an unchanged delegate, or null. A combining operation returns null when the result of the operation is a delegate that does not reference at least one method. A combining operation returns an unchanged delegate when the requested operation has no effect.</p> </blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/system.delegate.combineimpl.aspx" rel="nofollow">Delegate.CombineImpl Method</a> shows the implementation.</p> <p>I looked over the implementation of Delegate and MulticastDelegate in the .NET 4 source code. Neither of them declare the += or -= operator. Coming to think of it, in Visual Basic.NET you don't even have them, you use AddHandler, etc... </p> <p>This means that the C# compiler implements this functionality and that the type doesn't really have anything to do with defining specialized operators.</p> <p>So this leads me to a logical conclusion which is, when you do:</p> <pre><code>EventHandler handler = MyEvent; </code></pre> <p>the C# compiler translates it to</p> <pre><code>EventHandler handler = EventHandler.Combine(MyEvent) </code></pre> <p>I'm surprised how quickly this question was solved thanks to your help.</p> <p>Thank you very much indeed!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload