C#/C# 연습

기초 연습 01

HicKee 2022. 11. 25. 16:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test1 {
    public struct Cats {
        public int birth_month;
        public string cat_name;
    }

    class Program {
        static void Main(string[] args) {
            Cats cat  = new Cats();
            cat.birth_month = 10;
            cat.cat_name = "나비";

            Console.WriteLine("cat.birth_month : {0}" , cat.birth_month);
            Console.WriteLine("cat.cat_name : {0}",cat.cat_name);
            Console.WriteLine();

            Cats change_cat = cat;
            Console.WriteLine("=======바꿈=======");
            Console.WriteLine("바뀐 cat2 birth : {0}", change_cat.birth_month);
            Console.WriteLine("바뀐 cat2 name : {0}", change_cat.cat_name);

            change_cat.birth_month = 12;
            change_cat.cat_name = "꼬미";

            Console.WriteLine("=======바꿈=======");
            Console.WriteLine("바뀐 cat2 birth : {0}", change_cat.birth_month);
            Console.WriteLine("바뀐 cat2 name : {0}", change_cat.cat_name);

            Console.WriteLine("");


        }
    }
}

'C# > C# 연습' 카테고리의 다른 글

Variable : 변수  (0) 2022.11.27
MaxValue 와 MinValue  (0) 2022.11.26
C# 연산자 : Bool, 논리 연산자  (0) 2022.11.14
C# 연산자 : 문자열  (0) 2022.11.14
C# namespace : 네임스페이스  (0) 2022.11.13