第1个回答 2010-05-20
静态类不是不需要构造函数,而是不能定义普通的构造函数。
但是静态类可以定义静态构造函数。
“Static classes are sealed and therefore cannot be inherited. They cannot inherit from any class except Object. Static classes cannot contain an instance constructor; however, they can have a static constructor. For more information, see Static Constructors (C# Programming Guide). ”这是MSDN的官方说明。
举例:
static StaticClassSample {
static int Count = 0;
//public StaticClassSample () {} wrong
static StaticClassSample () {
Count = 0;
}
}本回答被网友采纳