根据 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.
谁能解释一下为什么静态构造函数不能有参数?
最佳答案
正如 MSDN 所说,在创建第一个实例之前会自动调用静态构造函数来初始化类。因此您不能向它发送任何参数。
如果 CLR 必须调用静态构造函数,它如何知道要传递哪些参数?
关于c# - 为什么静态构造函数没有任何参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6771890/