Static Properties : Static Properties : Class C# Examples


C# Examples » Class » Static Properties »

 

Static Properties









    
using  System;

class  MyClass
{
      static  int  myValue;

      public  static  int  StaticProperty
      {
            set  {  myValue  =  value;  }
            get  {  return  myValue;  }
      }

}

class  MainClass
{
      static  void  Main()
      {
            Console.WriteLine("Init  Value:  {0}",  MyClass.StaticProperty);
            MyClass.StaticProperty  =  10;
            Console.WriteLine("New  Value  :  {0}",  MyClass.StaticProperty);
      }
}
    
   
  
   



Output

Init Value: 0
New Value : 10


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Static Properties