Search code examples
c#.netoopstatic-methods

Why does a static constructor not have any parameters?


Per MSDN:

A static constructor does not take access modifiers or have parameters.

A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.

A static constructor cannot be called directly.

Can any one please explain why can't the static constructor have parameters?


Solution

  • As MSDN says, A static constructor is called automatically to initialize the class before the first instance is created. Therefore you can't send it any parameters.

    If the CLR must call a static constructor how will it know which parameters to pass it?