A class with method and member variables : Member Variable : Class C# Examples


C# Examples » Class » Member Variable »

 

A class with method and member variables









    
using  System;

class  Employee
{
        //  constructor
        public  Employee(string  name,  float  billingRate)
        {
                this.name  =  name;
                this.billingRate  =  billingRate;
        }
        //  figure  out  the  charge  based  on  Employee's  rate
        public  float  CalculateCharge(float  hours)
        {
                return(hours  *  billingRate);
        }
        //  return  the  name  of  this  type
        public  string  TypeName()
        {
                return("Employee");
        }
        
        private  string  name;
        protected  float  billingRate;
}
class  MainClass
{
        public  static  void  Main()
        {
                Employee  Employee  =  new  Employee("A",  21.20F);
                Console.WriteLine("Name  is:  {0}",  Employee.TypeName());
        }
}
    
   
  
   



Output

Name is: Employee


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Member Variable