Note that there are some explanatory texts on larger screens.

plurals
  1. POc# inherited class initialization
    text
    copied!<p>so with this class i have</p> <pre><code>public class Options { public bool show { get; set; } public int lineWidth { get; set; } public bool fill { get; set; } public Color fillColour { get; set; } public string options { get; set; } public virtual void createOptions() { options += "show: " + show.ToString().ToLower(); options += ", lineWidth: " + lineWidth; options += ", fill: " + fill.ToString().ToLower(); options += ", fillColor: " + (fillColour != Color.Empty ? ColourToHex(fillColour) : "null"); } public Options(bool _show, int _lineWidth, bool _fill, Color _fillColour) { show = _show; lineWidth = _lineWidth; fill = _fill; fillColour = _fillColour; createOptions(); } } </code></pre> <p>and another class that inherits it</p> <pre><code>public class Line : Options { public static bool steps { get; set; } public override void createOptions() { options += ", lines: {"; options += " steps: " + steps.ToString().ToLower() + ","; base.createOptions(); options += "}"; } public Line(bool _show, int _lineWidth, bool _fill, Color _fillColour, bool _steps) : base(_show, _lineWidth, _fill, _fillColour) { steps = _steps; } } </code></pre> <p>When calling the object <code>Line(true, 1, true, Color.Gray, true)</code> it does the override of the inherited class function first, then sets <code>steps</code> to <code>true</code>.</p> <p>I want <code>steps</code> to be included in the override so <code>steps</code> will now be <code>true</code> instead of <code>false</code>(its default).</p> <p>If its possible please gimme some pointers and tips on how to fix this and explain to me why my setup will not allow for the override to happen after the constructor init.</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