Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First base class constructor is called followed by the derived class constructor. The result is 2. You should explicitly state the accessibility of that class variable. Is it protected, private or public?</p> <p>I see you changed it to public now, so it will be 2.</p> <p>This link will further help you understand constructors, how they are used, when they are called, and order of constructor call when you use inheritance:</p> <p><a href="http://www.yoda.arachsys.com/csharp/constructors.html" rel="nofollow noreferrer">http://www.yoda.arachsys.com/csharp/constructors.html</a></p> <p>Also you may want to actually try this out yourself, you will learn more by practicing and writing code then just reading it.</p> <p>Try to declare Bar and output its value. Use some properties:</p> <pre><code> class Foo { public int abc; public Foo() { abc = 3; } public int ABC { get { return abc; } set { abc = value; } } } class Bar : Foo { public Bar() : base() { abc = 2; } } class Program { static void Main(string[] args) { Bar b = new Bar(); Console.WriteLine(b.ABC); Console.ReadLine(); } } </code></pre> <p>A simple printout would yield the result you are looking for. Here is the output:</p> <p><a href="http://img141.imageshack.us/img141/9238/rrrrr.jpg" rel="nofollow noreferrer">alt text http://img141.imageshack.us/img141/9238/rrrrr.jpg</a></p> <p>Don't you just love my <code>namespace</code> :-). By the way you could also use automatic properties so that the property is simply public int ABC {get;set;}.</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. 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