Hi,
Say I have a class Student which has a static field Count. I need to increment it whenever a new object of Student is created and decrement it whenever any object of Student is destroyed.
I know that increment can be done in the constructor but what about decrement, since there is no destructor.
Decrement a static variable of a class after an object it has been destroyed
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Bechir BejaouiRank #144 · 15.9K reputationPosted Mar 14, 2009, 7:43 AM EDT
class Student : IDisposable
{
....................
public void Dispose()
{
Student.Decrement();
}
}