[Mono-list] Fwd: Static constructor issue

Andreas Färber andreas.faerber at web.de
Thu Sep 7 14:21:10 EDT 2006


Sorry...

Anfang der weitergeleiteten E-Mail:

> Von: Andreas Färber <andreas.faerber at web.de>
> Datum: 7. September 2006 20:19:58 MESZ
> An: "Abe Gillespie" <abe.gillespie at gmail.com>
> Betreff: Re: [Mono-list] Static constructor issue
>
> Hi,
>
> Am 07.09.2006 um 20:09 schrieb Abe Gillespie:
>
>> I'm not sure if this is your situation (you left out the necessary
>> details) ... but you need to call your base class's constructor
>> directly like so:
>>
>> class Parent
>> {
>>  public Parent(int foo)
>>  {
>>    // Do something with foo ...
>>  }
>> }
>>
>> class Child : Parent
>> {
>>  public Child(int foo) : base(foo)
>>  {
>>    // Do something specific with Child.
>>  }
>> }
>>
>> Good luck!
>> -Abe
>
> No, I wasn't talking of instance constructors. An example:
>
> class Parent {
> 	static Parent() {
> 		// important stuff
> 	}
> 	public Parent(int foo) {
> 	}
> }
>
> class Child : Parent {
> 	static Child() {
> 		// stuff that relies on "important stuff"
> 	}
> 	public Child(int foo) : base(foo) {
> 	}
> }
>
> Code then does new Child(42);.
>
> I would assume that before Child.cctor is called, Parent.cctor  
> would need to be called by the runtime - which apparently is not  
> happening. So I'm wondering whether this is a Mono issue or whether  
> it is intended that way.
>
> Andreas

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20060907/1544f5cd/attachment-0001.html 


More information about the Mono-list mailing list