Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a simple answer: no, C# does not allow it in the same way as in Delphi. </p> <p>For those knowing C# but not Delphi, this is what is meant: <a href="http://docwiki.embarcadero.com/RADStudio/en/Implementing_Interfaces" rel="nofollow">http://docwiki.embarcadero.com/RADStudio/en/Implementing_Interfaces</a> , see the "Implementing Interfaces by Delegation (Win32 only)" section.</p> <p>I guess you will have to pass the method calls to the interface manually. My C# is a litle bit rusty (I can still read it very well, though):</p> <pre><code>public class Blah : ISomeInterface { public ISomeInterface implementer { getter and setter here } public int ISomeInterface.DoThis() { if (implementer) return implementer.DoThis(); } public void ISomeInterface.DoThat(int param) { if (implementer) implementer.DoThat(param); } etc... </code></pre> <p>Where <code>DoThis</code> and <code>DoThat</code> are methods of <code>ISomeInterface</code> that must be implemented by <code>Blah</code>. In C#, you must explicitly delegate each of these methods to the contained interface. In Delphi, this is done automatically (i.e. the methods are generated and called behind the scenes, invisibly to the user), when you use the <code>implements</code> keyword after a property of a <code>class</code> or <code>interface</code> type.</p> <p>I assume that some of the answerers are confused by the use of the terms <code>implements</code> and <code>delegation</code>, which have a different meaning in C#.</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