Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Compose out the functionality? This is better for Single Responsibility. You'd have to think carefully about your constructors.</p> <pre><code>interface IAdminPage { public string AdminPageMethod(); } interface IJQueryPage { public string JQueryPageMethod(); } internal class AdminPage : IAdminpage { private string someString; internal AdminPage(string value) { this.someString = value; } public string AdminPageMethod() { return "AdminPage result with some string: " + this.someString; } } internal JQueryPage : IJQueryPage { private int someNumber; internal JQueryPage(int value) { this.someNumber = value; } public string JQueryPageMethod() { return "JQueryPage result with number: " + this.someNumber; } } class AdminJQueryPage : IQueryPage, IAdminpage { private readonly IAdminPage adminPage; private readonly IJQueryPage jqueryPage; public AdminJQueryPage(string someString, int someNumber) { this.adminPage = new AdminPage(someString); this.jqueryPage = new JQueryPage(someNumber); } public string AdminPageMethod() { return this.adminPage.AdminPageMethod(); } public string JQueryPageMethod() { return this.adminPage.JQueryPageMethod(); } } </code></pre> <p>If you really want multiple inheritance, look at Scala's <a href="http://www.scala-lang.org/node/126" rel="nofollow noreferrer">traits</a></p> <p><em>Edit</em>: added passing of constructor values to composed out classes. Also made the classes internal (cannot be accessed or constructed outside the assembly) because they are only ever constructed by the <code>AdminJQueryPage</code> class, which is the 'public-facing' class.</p>
 

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