测试一:
class Base
{
static Base()
{
Console.WriteLine("Static Base");
}
public Base()
{
Console.WriteLine("Base");
}
}
static void Main(string[] args)
{
Base b = new Base();
Console.Read();
}
打印结果:
Static Base
Base
测试二:
class Child : Base
{
static Child()
{
Console.WriteLine("Static Child");
}
public Child()
{
Console.WriteLine("Child");
}
}
在测试一的基础上增加子类,实例化子类
打印结果:
Static Child
Static Base
Base
Child
测试三: