[Mono-list] Static constructor issue

Kornél Pál kornelpal at gmail.com
Thu Sep 7 17:40:06 EDT 2006


>>> The reason why it's different for instance ctors is because you call
>>> the Parent ctor specifically before the code inside the Child ctor
>>> runs.
>> I'm not sure that metaphor is really useful :-)
> I second that :-)
> Either way this is what it is and we'll have to live with it.

Just to make sure that everything is clear:

Static constructors are not part of inheritance. Static constructors are 
called when you access the class that declares the static constructor. The 
reason because static constructors are called in "reverse order" is because 
the static constructor is executed before the constructor of the child class 
calls its parent's constructor, in other words: when it's is used for the 
first time.

So there is nothing special with static constructors. They are simply 
executed before their first member is accessed.


More information about the Mono-list mailing list