Static Constructors in C#
Random tidbit I learned at work yesterday:
Static constructors are called when one of the following two things happen:
- The first instance of the class with the static constructor is instantiated
- Any static member of that class is used
However, when a struct declares a static constructor, #1 does not apply. That is to say, instantiating an instance of that struct does not actually force the static constructor to be called. #2 is still true for structs, however.
That concludes my geek moment for the day.