"pedestrian via DotNetMonster.com" <u16758@xxxxxx> wrote in message
> Why is the instantiation of a Tire and subsequent Tire instantiation
> didn't call the constructor? I never see the Console.WriteLine text being
> I appreciate your explanation.
> Jack Jackson wrote:
>>The first instantiation of a Tire attempts to create a new Tire for
>>GoodStone. The creation of that Tire attempts to create a new Tire
>>for its Goodstone. The creation of that Tire attempts to create a new
>>Tire for its Goodstone.
>>You can see where this is going. It never gets past initializing
>>Goodstone in any instance.
>>[quoted text clipped - 11 lines]
>>>Yes, fields are initialized first...
>>>>Fields are initialized before the constructor code executes. That
>>>>the recursion with no output.
> Warmest Regards,
> Message posted via DotNetMonster.com
It never gets to the constructor code in any instance because EVERY instance
that is created is creating two new instances before the constructor is
called. There is no end condition to the "preconstructor" events in any of
the objects. I'm not sure that preconstructor is the right word, but it
basically means the initialization of all the members such as GoodStone and
Cycle 1: instance, field1 (GoodStone), field2 (FireYear)
Cycle 2: field11, field12, field21, field22
Cycle 3: field111, field112, field121, field122, field211,
field212, field221, field222
and so on...
The original instance constructor (Cycle 1 instance) never executs until all
the cycles are done. Obviously that won't happen.
Worse yet, the subsequent constructors (field1, field111, etc...) will not
execute until the end of the recursion.
Hope this helps...