K-digital traning/C#프로그래밍

열거형(enum)

내꺼블로그 2023. 7. 20. 12:01
using System;


namespace LearnDotnet
{
    internal class Program
    {
        enum Item
        {
            WEAPON,
            ARMOR,
            POTION
        }
        static void Main(string[] args)
        {
            Item weapon = Item.WEAPON;
            Item armor = Item.ARMOR;
            Item potion = Item.POTION;

            int intWeapon = 0;
            int intArmor = 1;
            int intPotion = 2;

            Console.WriteLine("{0}: {1}(value)", (Item)intWeapon, (int)weapon);
            Console.WriteLine("{0}: {1}(value)", (Item)intArmor, (int)armor);
            Console.WriteLine("{0}: {1}(value)", (Item)intPotion, (int)potion);
        }
    }
}

'K-digital traning > C#프로그래밍' 카테고리의 다른 글

반복문 for  (0) 2023.07.20
Input, enum 활용  (0) 2023.07.20
2023/07/19 과제  (0) 2023.07.19
스타크래프트 마린  (0) 2023.07.19
디아블로 아이템 사전  (0) 2023.07.19