Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to pass <code>values</code> or <code>variables</code> of the <code>derives class</code> to the <code>base class constructor</code> if the base class constructor does not have any <code>default parameterless constructor</code>.</p> <p>You dont need to declare anything in the base constructor call</p> <p>The main purpose of base keyword is to call the <code>base class constructor</code>.</p> <p>In general,if you do not declare any constructor of your own,the compiler creates a <code>default constructor</code> for you.</p> <p>But if you define your own constructor having <code>parameter</code>,then the compiler does not create the <code>default parameterless constructor</code>.</p> <p>So in the case where you dont have a default constructor declared in the base class and want to call a base class constructor having parameters,you have to call that base class constructor and pass the required values through <code>base</code> keyword</p> <p>Do it like this</p> <pre><code>public Basketball() : base (1,"user") </code></pre> <p><strong>OR</strong></p> <pre><code>public Basketball(int id,string n) : base (id,n) </code></pre> <p><strong>OR</strong></p> <pre><code>public Basketball(int id,string n) : base () </code></pre> <p><strong>OR</strong></p> <pre><code>public Basketball() : base () </code></pre> <p>is similar to </p> <pre><code>public Basketball()//calls base class parameterless constructor by default </code></pre> <p>It all depends on how you want your class to <strong>behave</strong> when the <code>derived</code> class is instantiated</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.
    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