コード例 #1
0
ファイル: MyClass1.cs プロジェクト: GSungJae/0923_sort-event-
        static void Main()
        {
            CPoint3D point = new CPoint3D();

            point.x = 20;
            point.y = 30;
            point.z = 5;

            Console.WriteLine(point.ToString());

            CPoint3D point1 = new CPoint3D();

            point1.x = 30;
            point1.y = 40;
            point1.z = 25;

            Console.WriteLine(point1.ToString());

            CPoint3D point2 = new CPoint3D(90, 30, 20);

            Console.WriteLine(point2.ToString());

            CPoint3D point3 = point2;

            point3.z = 900;

            Console.WriteLine(point2.ToString());
            Console.WriteLine(point3.ToString());
        }
コード例 #2
0
ファイル: Class1.cs プロジェクト: ohsangjin96/ConsoleApp0923
        static void Main()
        {
            //CPoint3D point;
            //point.x = 20;
            //point.y = 10;
            //point.z = 5;
            //Console.WriteLine(point.ToString());

            CPoint3D point1 = new CPoint3D();

            point1.x = 70;
            point1.y = 50;
            point1.z = 40;
            Console.WriteLine(point1.ToString());

            CPoint3D point2 = new CPoint3D(90, 30, 10);

            Console.WriteLine(point2.ToString());

            CPoint3D point3 = point2;

            point3.z = 900;
            Console.WriteLine(point2.ToString()); //?
            Console.WriteLine(point3.ToString()); //?

            Console.WriteLine(int.MinValue);
            Console.WriteLine(int.MaxValue);
        }
コード例 #3
0
        static void Main()
        {
            //CPoint3D point;
            //point.x = 20; //클래스는 반드시 new 해야함
            //point.y = 10;
            //point.z = 5;

            //Console.WriteLine(point.ToString());

            CPoint3D point1 = new CPoint3D();

            point1.x = 70;
            point1.y = 50;
            point1.z = 40;

            Console.WriteLine(point1.ToString());

            CPoint3D point2 = new CPoint3D(90, 30, 10); //구조체에서 생성자를 쓰는 이유는 34~37줄까지의 4줄을 쓰기 귀찮아서.

            Console.WriteLine(point2.ToString());

            CPoint3D point3 = point2;

            point3.z = 900;
            Console.WriteLine(point2.ToString());
            Console.WriteLine(point3.ToString());  //ref타입은 밸류로 하더라도 같이 영향을 받는다. 클래스와 구조체를 선택하는 기준.
        }