Exemple #1
0
        static void Main(string[] args)
        {
            BirthdayInfo origin = new BirthdayInfo();

            Console.WriteLine($"{origin.Name}, {origin.Birthday} 출생");
            Console.WriteLine($"{origin.Age}세");

            BirthdayInfo info = new BirthdayInfo
            {
                Name     = "박서현",
                Birthday = new DateTime(1991, 6, 28)
            };

            Console.WriteLine($"{info.Name}, {info.Birthday} 출생");
            Console.WriteLine($"{info.Age}세");

            var myIns = new { Name = "성명건", Home = "창원" };

            Console.WriteLine($"{myIns.Name} / {myIns.Home}");
            //
            var b = new { Subject = "수학", Scores = new int[] { 99, 88, 77 } };

            Console.WriteLine($"{b.Subject}");
            foreach (var item in b.Scores)
            {
                Console.WriteLine($"{item}");
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            BirthdayInfo info = new BirthdayInfo();

            Console.WriteLine($"알수없는이름 : {info.Name}");
            info.Name = "yj";
            //info.SetName("yj");//set
            info.Birthday = new DateTime(1996, 04, 30);
            //info.SetBirthday(new DateTime(1996, 04, 30));//set


            //Console.WriteLine(info.GetName());
            //Console.WriteLine(info.GetBirthday());
            //Console.WriteLine($"이름 : {info.GetName()}, 출생 : {info.GetBirthday()}");
            Console.WriteLine($"이름 : {info.Name}, 출생 : {info.Birthday}, 나이 : {info.Age}");

            //318p 무명형식
            var myInstance = new { Name = "yj", Home = "busan" };

            Console.WriteLine($"{myInstance.Name},{myInstance.Home}");
            //myInstance.Name = "yyj"; 불가능함
            var b = new { Subject = "su", Scores = new int[] { 90, 80, 70, 60 } };

            Console.Write($"Subject : {b.Subject}, Scores : ");
            foreach (var score in b.Scores)
            {
                Console.Write($"{score} ");
            }
            Console.WriteLine();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            BirthdayInfo info = new BirthdayInfo();

            //info.SetName("이하영");
            //info.SetBirthday(new DateTime(1993, 9, 17));

            //Console.WriteLine($"Name : {info.GetName()}");
            //Console.WriteLine($"Birthday : {info.GetBirthday()}");

            info.Name     = "이하영";
            info.Birthday = new DateTime(1993, 9, 17);

            Console.WriteLine($"Name : {info.Name}");
            Console.WriteLine($"Birthday : {info.Birthday}");
            Console.WriteLine($"Age : {info.Age}");

            var myInstance = new { Name = "이하영", Home = "부산" };

            Console.WriteLine($"{myInstance.Name} / {myInstance.Home}");
            //myInstance.Home = "서울"; //변경 불가능 가져다 쓰는 것만 가능

            var b = new { Subject = "수학", Scores = new int[] { 99, 88, 77 } };

            Console.WriteLine($"{b.Subject}");
            foreach (var item in b.Scores)
            {
                Console.Write($"{item} ");
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            BirthdayInfo bi = new BirthdayInfo();

            bi.Name     = "이예은";
            bi.Birthday = new DateTime(1993, 10, 31);

            Console.WriteLine($"{bi.Name}, {bi.Birthday}출생");
            Console.WriteLine($"{bi.Age}세");

            // bi.SetName("이예은");
            // bi.SetBirthday(new DateTime(1993, 10, 31));
            //Console.WriteLine($"{bi.GetName()}, {bi.GetBirthday()} 출생");

            var myInstance = new { Name = "이예은", Home = "양산" };

            Console.WriteLine($"{myInstance.Name}, {myInstance.Home}");

            var v = new { Subject = "수학", Scores = new int[] { 99, 88, 77 } };

            Console.WriteLine($"{v.Subject}");
            foreach (var item in v.Scores)
            {
                Console.WriteLine($"{item}");
            }
        }
        static void Main(String[] args)
        {
            BirthdayInfo birth = new BirthdayInfo();

            birth.Name     = "red";
            birth.Birthday = new DateTime(1996, 01, 01);
            Console.WriteLine($"Name : {birth.Name}");
            Console.WriteLine($"Birthday : {birth.Birthday}");
            Console.WriteLine($"Age : {birth.Age}");
        }
Exemple #6
0
        static void Main(string[] args)
        {
            BirthdayInfo info = new BirthdayInfo
            {
                Name     = "박서준",
                Birthday = new DateTime(1988, 12, 16)
            };

            WriteLine($"{info.Name}은 {info.Birthday} 출생이며 {info.Age}살 입니다.");
        }
Exemple #7
0
        static void Main(string[] args)
        {
            BirthdayInfo birth = new BirthdayInfo();

            birth.Name     = "민서";
            birth.Birthday = new DateTime(1000, 01, 01);
            Console.WriteLine($"Name : {birth.Name}");
            Console.WriteLine($"Birthday : {birth.Birthday.ToShortDateString()}");
            Console.WriteLine($"Age : {birth.Age}");
        }
Exemple #8
0
        static void Main(string[] args)
        {
            BirthdayInfo birth = new BirthdayInfo();

            birth.Name     = "Charlie";
            birth.Birthday = new DateTime(1994, 10, 24);

            Console.WriteLine($"Name : {birth.Name}");
            Console.WriteLine($"Birthday : {birth.Birthday.ToShortDateString()}");
            Console.WriteLine($"Age : {birth.Age}");
        }
Exemple #9
0
        static void Main(string[] args)
        {
            BirthdayInfo birth = new BirthdayInfo();

            birth.Name     = "서현";
            birth.Birthday = new DateTime(1991, 6, 28);

            WriteLine($"Name : {birth.Name}");
            WriteLine($"Birthday : {birth.Birthday.ToShortDateString()}");
            WriteLine($"Age : {birth.Age}");
        }
Exemple #10
0
        static void Main(string[] args)
        {
            BirthdayInfo birth = new BirthdayInfo();

            birth.Name     = "수영";                       //Name의 set
            birth.Birthday = new DateTime(2000, 10, 19); //Birthday의 set
            //     birth.Age = 2020;
            Console.WriteLine(birth.Name);               //Name의 get
            Console.WriteLine(birth.Birthday);           //Birthday의 get
            Console.WriteLine(birth.Age);                //Age의 get
        }
Exemple #11
0
        static void Main(string[] args)
        {
            BirthdayInfo birth = new BirthdayInfo();

            birth.Name     = "서현";
            birth.Birthday = new DateTime(1991, 6, 28);

            Console.WriteLine("Name : {0}", birth.Name);
            Console.WriteLine("Birthday : {0}", birth.Birthday.ToShortDateString());
            Console.WriteLine("Age : {0}", birth.Age);
        }
Exemple #12
0
        static void Main(string[] args)
        {
            BirthdayInfo birth = new BirthdayInfo("나연");

            birth.Birthday = new DateTime(1995, 9, 22);

            Console.WriteLine("이름 : {0}", birth.Name);
            Console.WriteLine("생일 : {0}", birth.Birthday);
            Console.WriteLine("나이 : {0}", birth.Age);

            Console.ReadKey();
        }
Exemple #13
0
        static void Property()
        {
            WriteLine("Property()");

            BirthdayInfo birth = new BirthdayInfo();

            birth.Name     = "서현";
            birth.Birthday = new DateTime(1991, 6, 28);

            WriteLine($"Name : {birth.Name}");
            WriteLine($"Birthday : {birth.Birthday}");
            WriteLine($"Age : {birth.Age}");
        }
Exemple #14
0
        static void ConstructorWithProperty()
        {
            WriteLine("\nConstructorWithProperty()");

            BirthdayInfo birth = new BirthdayInfo()
            {
                Name     = "서현",
                Birthday = new DateTime(1991, 6, 28)
            };

            WriteLine($"Name : {birth.Name}");
            WriteLine($"Birthday : {birth.Birthday}");
            WriteLine($"Age : {birth.Age}");
        }
Exemple #15
0
        static void Main(string[] args)
        {
            //기본, 자동 프로퍼티
            //BirthdayInfo birth = new BirthdayInfo();
            //birth.Name = "SoulSeek";
            //birth.Birthday = new DateTime(1982, 12, 07);

            //생성자에서 프로퍼티 사용
            BirthdayInfo birth = new BirthdayInfo()
            {
                Name     = "SoulSeek",
                Birthday = new DateTime(1982, 12, 07)
            };

            Console.WriteLine("Name : {0}", birth.Name);
            Console.WriteLine("Birthday : {0}", birth.Birthday.ToShortDateString());
            Console.WriteLine("Age : {0}", birth.Age);

            Console.ReadLine();
            Console.ReadKey();
        }
Exemple #16
0
        static void Main(string[] args)
        {
            BirthdayInfo info = new BirthdayInfo()
            {
                Name     = "서현",
                Birthday = new DateTime(1991, 6, 28)
            };

            Console.WriteLine($"{info.Name},{info.Birthday}");
            Console.WriteLine($"{info.Age}");

            var myIns = new { Name = "송정윤", Home = "남천" };

            Console.WriteLine($"{myIns.Name},{myIns.Home}");

            var b = new { Subject = "수학", Scores = new int[] { 99, 88, 77 } };

            Console.WriteLine($"{b.Subject}");
            foreach (var item in b.Scores)
            {
                Console.WriteLine($"{item}");
            }
        }
Exemple #17
0
        static void Main(string[] args)
        {
            BirthdayInfo info = new BirthdayInfo();

            info.Name     = "송상근";
            info.Birthday = new DateTime(1993, 09, 01);//값을 변수처럼 대입해줄 수 있음
            Console.WriteLine($"Name:{info.Name}");
            Console.WriteLine($"Birthday : {info.Birthday.ToShortDateString()}");
            Console.WriteLine($"Age:{info.Age}");
            Console.WriteLine($"PhoneNumber:{info.PhoneNumber}");

            Console.WriteLine();

            BirthdayInfo info2 = new BirthdayInfo();

            Console.WriteLine($"Name Default:{info2.Name}");

            //info.SetName("송상근"); //값을 매개변수로 넘겨준다.
            //info.SetBirthday(new DateTime(1993, 09, 01));
            //Console.WriteLine(info.GetName());
            //Console.WriteLine(info.GetBirthday());
            //Console.WriteLine($"{info.GetName()},{info.GetBirthday()}");
        }
Exemple #18
0
        static void Main(string[] args)
        {
            BirthdayInfo info = new BirthdayInfo();

            //info.SetName("박서현");
            //info.SetBirthday(new DateTime(1991, 6, 28));
            //Console.WriteLine($"{info.GetName()}, {info.GetBirthDay()}출생");
            info.Name     = "박서현";
            info.Birthday = new DateTime(1991, 6, 28);
            Console.WriteLine($"{info.Name}, {info.Birthday}출생");
            Console.WriteLine($"{info.Age}세");

            var myIns = new { Name = "손유진", Home = "부산" };

            Console.WriteLine($"{myIns.Name} / {myIns.Home}");

            var b = new { Subject = "수학", Scores = new int[] { 99, 88, 77 } };

            Console.WriteLine($"{b.Subject}");
            foreach (var item in b.Scores)
            {
                Console.WriteLine($"{item}");
            }
        }