Predict the Output Challenge in C#, part 3
volatileread.com
volatileread.com
I would have liked the descriptions/answers to be a bit more detailed though. For example, why is the static constructor called only after the instance constructor (in part 2)? As far as I can see in the docs, this should not be the case?
The static variable depends on the instance. So static gets called first and starts running, but before it could call the Console.WriteLine, instance of Singleton gets created due to the above line and hence the instance constructor.