質問

I am looking at this excellent article from Jon Skeet.

While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article:

The runtime could decide to run the type initializer on loading the assembly to start with... Or perhaps it will run it when the static method is first run... Or even wait until the field is first accessed...

When I try this out (on framework 4), I always get the first result. That is, the static method is initialized before the assembly is loaded. I have tried running this multiple times and get the same result. (I tried both the debug and release versions)

Why is this so? Am I missing something?

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません softwareengineering.stackexchange
scroll top