各實例間共享類的靜態(tài)變量
public class Test
{
private static int a;
public int GetA()
{
return a;
}
public void SetA(int i)
{
a = i;
}
}
var t1 = new Test();
var t2 = new Test();
t1.SetA(1);
Console.WriteLine(t2.GetA()); //1
t2.SetA(2);
Console.WriteLine(t1.GetA()); //2