Member Functions : Member Method : Class C# Examples


C# Examples » Class » Member Method »

 

Member Functions









    
using  System;

class  Point
{
        public  Point(int  x,  int  y)
        {
                this.x  =  x;
                this.y  =  y;
        }
        
        //  accessor  functions
        public  int  GetX()  {
                return(x);
        }
        public  int  GetY()  {
                return(y);
        }
        
        //  variables  now  private
        int  x;
        int  y;
}

class  MainClass
{
        public  static  void  Main()
        {
                Point  myPoint  =  new  Point(10,  15);
                Console.WriteLine("myPoint.X  {0}",  myPoint.GetX());
                Console.WriteLine("myPoint.Y  {0}",  myPoint.GetY());
        }
}
    
   
  
   



Output

myPoint.X 10
myPoint.Y 15


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Member Method