Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is <a href="http://msdn.microsoft.com/en-us/library/vstudio/ms173115.aspx">constructor chaining</a>. Essentially, you're calling a different constructor before executing the contents of that constructor.</p> <pre><code>public class Foo { public Foo() : this("Hello") { Console.Write(" World!"); } public Foo(string text) { Console.Write(text); } } new Foo(); //outputs "Hello World!" </code></pre> <p>So somewhere in your <code>BarListTracker</code> there should be another constructor that takes either a <code>BarInterval[]</code> array or an <code>IEnumerable&lt;BarInterval&gt;</code> like this:</p> <pre><code>public class BarListTracker : GotTickIndicator { public BarListTracker(BarInterval interval) : this(new BarInterval[] { interval }) { //specific initialization for this constructor } public BarListTracker(BarInterval[] intervals) { //shared initialization logic for both constructors } } </code></pre> <p>It will execute the body <code>BarListTracker(BarInterval[])</code>, <em>then</em> execute the body of <code>BarListTracker(BarInterval)</code></p> <p>This is <em>generally</em> used to reduce code duplication. If you had some initialization code for your <code>BarListTracker</code>, it makes more sense to write it in one place and share that logic with your constructors rather than rewriting it for each one.</p> <p>In addition, it lets you pass in or modify the input parameters with basic expressions. So in this case, in-line with calling the <code>BarListTracker(BarInterval[])</code> constructor, it's wrapping the single <code>BarInterval interval</code> object as an array to match the signature. Likely this is just a convenience overload to provide a simpler API for programmers who may often have only a single <code>BarInterval</code> to construct the tracker with.</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