A static variable allows you to count instances of a class, by adding 1 to the variable each time you pass through the constructor.
class Foo
{
static int counter;
foo()
{
counter++;
}
static void main()
{
Foo bar = new Foo();
Foo poo = new Foo();
Console.writeline(counter());
}
}
NB: Did you also post this question:
http://www.codeproject.com/Messages/5167614/Using-static-var-on-a-class.aspx[
^], under a different user id?