Mega Code Archive

 
Categories / C# Tutorial / Class
 

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());     } } myPoint.X 10 myPoint.Y 15