static void Main(string[] args) { Point point; //== int x //point = new Point(); // x=0,y=0; new 키워드 쓰면 기본값으로 초기화해준다. point.x = 10; point.y = 10; Pointclass pointClassA = new Pointclass(10, 20); Pointclass pointClassB = pointClassA; pointClassB.x = 100; pointClassB.y = 200; Console.WriteLine("pointClassA : " + pointClassA.x + "," + pointClassA.y); Console.WriteLine("pointClassB : " + pointClassB.x + "," + pointClassB.y); PointStruct pointStructA = new PointStruct(10, 20); PointStruct pointStructB = pointStructA; pointStructB.x = 100; pointStructB.y = 200; Console.WriteLine("pointStructA : " + pointStructA.x + "," + pointStructA.y); Console.WriteLine("pointStructB : " + pointStructB.x + "," + pointStructB.y); }
static void Main(string[] args) { Point point; point.x = 10; point.y = 10; Console.WriteLine("X: " + point.x); Console.WriteLine("Y: " + point.y); Pointclass pointclassA = new Pointclass(10, 20); Pointclass pointclassB = pointclassA; pointclassB.x = 100; pointclassB.y = 200; Console.WriteLine("pountClassA: " + pointclassA.x + ", " + pointclassA.y); Console.WriteLine("pountClassB: " + pointclassB.x + ", " + pointclassB.y); Console.WriteLine(""); //구조체 PointStruct pointStructA = new PointStruct(10, 20); PointStruct pointStructB = pointStructA; pointStructB.x = 100; pointStructB.y = 200; Console.WriteLine("pointStructA: " + pointStructA.x + ", " + pointStructA.y); Console.WriteLine("pointStructB: " + pointStructB.x + ", " + pointStructB.y); }