[转载]静态构造函数
class Program
{
static void Main(string[] args)
{
Caculator ca = new Caculator();
Caculator ca1 = new Caculator();
Console.WriteLine("Current object count is : " + Caculator.InstanceCount.ToString());
Console.ReadLine();
}
}
public class Caculator
{
public static int InstanceCount;
static Caculator()
{
InstanceCount++;
}
public Caculator()
{
InstanceCount++;
}
}
这个的输出结果是多少呢~~~{
static void Main(string[] args)
{
Caculator ca = new Caculator();
Caculator ca1 = new Caculator();
Console.WriteLine("Current object count is : " + Caculator.InstanceCount.ToString());
Console.ReadLine();
}
}
public class Caculator
{
public static int InstanceCount;
static Caculator()
{
InstanceCount++;
}
public Caculator()
{
InstanceCount++;
}
}
3