Static Member Functions : static method « Class « C# / CSharp Tutorial






using System;

class MyClass {
    public MyClass()
    {
        instanceCount++;
    }
    public static int GetInstanceCount()
    {
        return(instanceCount);
    }
    static int instanceCount = 0;
}

class MainClass
{
    public static void Main()
    {
        MyClass my = new MyClass();
        Console.WriteLine(MyClass.GetInstanceCount());
    }
}
1








7.45.static method
7.45.1.Use static
7.45.2.Static Member Functions