Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Good catch. This looks like it's <em>possibly</em> a bug in the C# compiler - I'll ping Eric Lippert to see what he thinks. (<code>dynamic</code> can be a bit tricksy; there may well be a perfectly good but non-obvious reason for this error.)</p> <p>EDIT: <strong>The code below appears <em>not</em> to work after all.</strong> I could have sworn I had it working this morning... I'm very confused as to what's going on. As per Simon's comments, the code fails with a message saying it's not supported by the language.</p> <p>Note that if you <em>do</em> use explicit interface implementation, it appears to compile just fine:</p> <pre><code>// Doesn't actually compile - see edit above class MyInterface : IMyInterface { private Action&lt;dynamic&gt; foo; event Action&lt;dynamic&gt; IMyInterface.OnSomeEvent { // TODO (potentially): thread safety add { foo += value; } remove { foo -= value; } } } </code></pre> <hr> <p>EDIT: The rest of this answer still stands...</p> <p>Note that you can't specify a field-like event as an explicitly-implemented event, i.e. this doesn't work:</p> <pre><code>event Action&lt;dynamic&gt; IMyInterface.OnSomeEvent; </code></pre> <p>It gives the following error message:</p> <blockquote> <p>Test.cs(15,39): error CS0071: An explicit interface implementation of an event must use event accessor syntax </p> </blockquote> <p>And if you <em>just</em> try to change to the event accessor syntax, you get the same error as the original code.</p> <p>Note that changing the event to a property works fine with an auto-implemented property implementation.</p>
    singulars
    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. 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