using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;

namespace LearnDotnet
{

    internal class Program
    {
        enum items
        {
            None = -1,
            WEAPON,
            AMOR,
            Potion

        }

        static void Main(string[] args)
        {

            // item의 종류 
            // 무기, 방어구, 물약 상수로 정의 
            const int Weapon = 0;
            const int Armor = 1;
            const int Potion = 2;

            //열거형식 변수를 정의 하고 변수의 값을 할당후 출력 
            items item = items.WEAPON;
            Console.WriteLine("item: {0}", item);
            //또한 열거형식 맴버를 정수형으로 캐스팅 하고 
            int itemNum = (int)item;
            Console.WriteLine("itemNum: {0}", itemNum);
            //정수형식을 다시 열거형으로 캐스팅 하는 연습을 해보자 
            item = (items)itemNum;
            Console.WriteLine("item: {0}", item);





        }
    }
}
반응형

'KDT > C# 프로그래밍' 카테고리의 다른 글

5번 문제  (0) 2023.07.20
4번 문제  (0) 2023.07.20
3번 문제  (0) 2023.07.20
2번문제  (0) 2023.07.20
1번 문제  (0) 2023.07.20

+ Recent posts