During the last interview, I was asked about the usefulness of the static constructor and could not answer the question. After the query, the statement is as follows:
Http://msdn2.microsoft.com/zh-cn/library/k9x6w0hc (vs.80). aspx
Static constructors have the following features:
The static constructor neither has an access modifier nor a parameter.
Before creating the first instance or referencing any static member, the class is automatically initialized by calling the static constructor.
Static constructor cannot be called directly.
InProgramThe user cannot control when to execute the static constructor.
A typical use of a static constructor is to use this constructor to write entries to a log file when the class uses a log file.
Static constructors are not hostedCodeThis constructor can also be called to create a packaging class.LoadlibraryMethod.