Keld Ølykke wrote:
The only thing you can be certain about is that constructors are chained e.g. new Y() will call the constructor of Y that as its first statement will call the constructor of A, etc.... all the way up til the contructor of Object.
Maybe it's because I'm tired, but that reads to me like you're saying that instantiating an object will trigger the constructor all the way up the chain. If you are, this isn't the case. If you don't specify base on the constructor call, you stop at that point. What do you think gets printed out here:
public abstract MyBaseClass
{
public MyBaseClase() { Console.WriteLine("I'm in the base class constructor.");
}
public class MyDerivedClass : MyBaseClass
{
public MyDerivedClass() { Console.WriteLine("I'm in the derived class constructor");
}
....
MyDerivedClass myClass = new MyDerivedClass();