Readonly property : Properties : Class C# Examples


C# Examples » Class » Properties »

 

Readonly property









    
using  System;

class  MyClass
{
      public  double  A  =  3;
      public  double  B  =  4;
      
      public  double  MyValue                                                        
      {
            get  {  return  A  *  B  ;  }          
      }
}

class  MainClass
{
      static  void  Main()
      {
            MyClass  c  =  new  MyClass();
            Console.WriteLine("MyValue:  {0}",  c.MyValue);
      }
}
    
   
  
   



Output

MyValue: 12


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Properties