【发布时间】:2011-03-01 20:53:47
【问题描述】:
我在工作中看到了这样的代码:
class FooPlugin : IPlugin // IPlugin is a Microsoft CRM component, it has something special about it's execution
{
static FooPlugin()
{
SomeObject.StaticFunction(); // The guy who wrote it said it's meaningful to this question but he can't remember why.
}
}
知道构造函数上的静态修饰符是什么意思吗?为什么在这种情况下需要它?
【问题讨论】:
-
实际上,静态构造函数上不允许使用所有修饰符,因此它只是静态 FooPlugin()。这也是自动调用的,无法按需执行。
-
@SWeko:你说得对,我忘了那里到底有什么。
标签: c#