123
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Structures { class Program { static void Main(string[] args) { Point p1; p1.X= 1; p1.Y = 2; p1.Display(); Point p2 = new Point(); p2.X = 1; p2.Y = 2; p2.Display(); } struct Point { public int X; public int Y; public Point(int XPos, int YPos) { X = XPos; Y = YPos; } // constructor public void Inc() { X++;Y++; } public void Dec() { X--; Y--; } public void Display() { Console.WriteLine("X={0},Y={1}", X, Y); } } } } |