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 |
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ObjectInitializers { class Program { static void Main(string[] args) { Point p1 = new Point(); // #1 p1.X = 10; p1.Y = 10; Point p2 = new Point(10,10);// #2 Point p3 = new Point{ X = 10, Y = 10 }; // #3 } } class Point { public int X { get; set; } public int Y { get; set; } public Point() { } public Point(int x, int y) { X = x; Y = y; } public void Display() { /*display on console*/ } } } |