Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Mystruct mr = new Mystruct(); //구조체를 생성 할 경우 매개변수값이 기본값으로 초기화가 이루어 진다.
            Mystruct mr;
            //생성된 객체 내에서의 매소드는 기본값으로 초기화 되어 있다.
            Mystruct mr2 = new Mystruct();
            Mystruct mr3 = new Mystruct(12);

            //Console.WriteLine($"{Mystruct.PI} {Mystruct.Age}");

            mr.Age = 10;
            Console.WriteLine($"{mr.Age}");
            Console.WriteLine($"{mr2.Age}");
            Console.WriteLine($"{mr3.Age}");
            Console.WriteLine($"{Mystruct.PI}");
            //mr.va = 10;//
            //Console.WriteLine($"{mr.va}");


            //구조체를 같은 구조체에 대입하게 되면 값이 복사 된다.
            Mystruct2 ar1, ar2;

            ar2.Age = 25;
            ar1     = ar2;

            Console.WriteLine($"{ar1.Age}");

            //-구조체는 값 형식이고 클래스는 참조 형식이다.
        }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     Mystruct.show();
     Mystruct.x = 20;
     Mystruct.show();
 }