Static Member Functions : Static method : Class C# Examples


C# Examples » Class » Static method »

 

Static Member Functions









    
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());
        }
}
    
   
  
   



Output

1


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Static method