728x90
using System;
using System.Runtime.InteropServices;
namespace LearnDotnet
{
internal class Program
{
enum Items
{
HELMS,
WEAPONS,
POTIONS
}
static void Main(string[] args)
{
//상수정의
const int HELMS = 0;
const int WEAPONS = 1;
const int POTIONS = 2;
//변수정의
Items items;
//값 할당
items = Items.POTIONS;
//값 출력
Console.WriteLine("items: {0}", items);
//Items -> int 형식 변환
int intItems = (int)items;
Console.WriteLine(intItems);
//int -> Items로 형식 변환
int intPotions = 2;
Items potions = (Items)intPotions;
Console.WriteLine("items: {0}", potions);
}
}
}
'KDT > C# 프로그래밍' 카테고리의 다른 글
23/07/20 퀴즈1 (0) | 2023.07.20 |
---|---|
enum 응용 (0) | 2023.07.20 |
디아블로 아이템5 (0) | 2023.07.20 |
스타크래프트 (마린 vs 저그) (0) | 2023.07.20 |
디아블로 아이템4 (0) | 2023.07.19 |