代码
using System;
//静态构造函数
namespace ConsoleApp4
{
class A {
public static int a;
static A() {
Console.WriteLine("A 静态构造");
a = 5;
}
public int b;
public A() {
Console.WriteLine("A 构造");
b = 6;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
A a = new A();
Console.WriteLine("a.b:" + a.b+ " A.a:" + A.a);
}
}
}