public class Class1
{
static int Count = 0;
public Class1()
{
Count++;
}
~Class1()
{
Count--;
}
public static int getCount()
{
return Count;
}
}
class Program
{
static void Main(string[] args)
{
Class1 obj;
for (int i = 0; i < 10; i++)
{
obj = new Class1();
Console.WriteLine("Current Count" + Class1.getCount());
}
Console.ReadLine();
}
}
{
static int Count = 0;
public Class1()
{
Count++;
}
~Class1()
{
Count--;
}
public static int getCount()
{
return Count;
}
}
class Program
{
static void Main(string[] args)
{
Class1 obj;
for (int i = 0; i < 10; i++)
{
obj = new Class1();
Console.WriteLine("Current Count" + Class1.getCount());
}
Console.ReadLine();
}
}
No comments:
Post a Comment