Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Point3D p3d1;

            p3d1.X = 10;
            p3d1.Y = 20;
            p3d1.Z = 40;

            Console.WriteLine(p3d1.ToString());

            Point3D p3d2 = new Point3D(100, 200, 300);
            Point3D p3d3 = p3d2;

            p3d3.Z = 400;

            Console.WriteLine(p3d2.ToString());
            Console.WriteLine(p3d3.ToString());
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Point3D p3d1; //Just declaration, but create instance.

            p3d1.X = 10;
            p3d1.Y = 20;
            p3d1.Z = 40;

            Console.WriteLine(p3d1.ToString());

            Point3D p3d2 = new Point3D(100, 200, 300); //using Constructor, instance create
            Point3D p3d3 = p3d2;                       //deep copy

            p3d3.Z = 400;

            Console.WriteLine(p3d2.ToString());
            Console.WriteLine(p3d3.ToString());
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Point3D p3d1;

            p3d1.x = 10;
            p3d1.y = 20;
            p3d1.z = 40;

            WriteLine(p3d1.ToString());

            Point3D p3d2 = new Point3D(100, 200, 300);
            Point3D p3d3 = p3d2;

            p3d3.z = 400;

            WriteLine(p3d2.ToString());
            WriteLine(p3d3.ToString());
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Point3D p3d1;   // 선언만으로도 인스턴스가 생성된다.

            p3d1.X = 10;
            p3d1.Y = 20;
            p3d1.Z = 40;

            Console.WriteLine(p3d1.ToString());

            Point3D p3d2 = new Point3D(100, 200, 300); // 생성자를 이용한 인스턴스 생성도 가능!
            Point3D p3d3 = p3d2;                       // 구조체의 인스턴스를 다른 인스턴스에 할당하면 깊은 복사가 이뤄진다.

            p3d3.Z = 400;

            Console.WriteLine(p3d2.ToString());
            Console.WriteLine(p3d3.ToString());
        }