A static constructor belongs to a class, not to an instance, which means that the constructor is only executed once . This is called automatically by. NET before the first instance is created or any static members are referenced.
1. Static constructor statically defined, no access modifier, no parameter, no return type. Because it is. NET calls, so modifiers like public and private are meaningless.
Class Test { ///<summary> ///static constructor/class constructor/// </summary> Static test () { } }
2, is when the first class instance is created or any static member is referenced. NET will automatically call the static constructor to initialize the class, which means that we cannot call the static constructor directly, and we cannot control when the static constructor is executed.
3. A class can have only one static constructor.
4. Parameterless constructors can coexist with static constructors. Although the parameter list is the same, one belongs to the class and one belongs to the instance, so there is no conflict.
5, run up to one time only.
6. Static constructors cannot be inherited.
7. If a static constructor is not written, and the class contains a static member with an initial value set, the compiler automatically generates a default static constructor.
No static constructors, no default static constructors are generated if static member declarations are declared but not initialized in a class; (http://blog.csdn.net/gxmark/article/details/6513752)
Static code blocks are only called when they are first used, only 1 times;
Static constructors are called before other constructors;
Static variable initialization--"static constructor--" member variable initialization--"General constructor
Constructors for C # static classes