日期:2014-05-19  浏览次数:20759 次

咋判断当前是否存在某个对象的实例?
如题。

------解决方案--------------------
如果你是想知道 类被实例化 了 多少个?
可以试试

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication4
{
public class test
{
public static int icount = 0;
public test()
{
icount++;
}

~test()
{
icount--;
}
}
class Program
{
static void Main(string[] args)
{
test a = new test();
test b = new test();
test c = new test();

Console.WriteLine(test.icount);
}
}
}
}