A Simple Class with member fields and constrctor : Class Definition : Class C# Examples


C# Examples » Class » Class Definition »

 

A Simple Class with member fields and constrctor









    
using  System;

class  Point
{
        //  constructor
        public  Point(int  x,  int  y)
        {
                this.x  =  x;
                this.y  =  y;
        }
        
        //  member  fields
        public  int  x;
        public  int  y;
}

class  MainClass
{
        public  static  void  Main()
        {
                Point  myPoint  =  new  Point(10,  15);
                Console.WriteLine("myPoint.x  {0}",  myPoint.x);
                Console.WriteLine("myPoint.y  {0}",  myPoint.y);
        }
}
    
   
  
   



Output

myPoint.x 10
myPoint.y 15


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Class Definition