Skip to content

Instantly share code, notes, and snippets.

@momoci99
Created May 2, 2018 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save momoci99/6eb06ebe6d9801ed90de627ae14d751d to your computer and use it in GitHub Desktop.
Save momoci99/6eb06ebe6d9801ed90de627ae14d751d to your computer and use it in GitHub Desktop.
Enum 코드
class Program
{
enum Day { Sun, Mon, Tue, Wed, Thu, Fri, Sat };
static void Main()
{
//정수형으로 형변환
int x = (int)Day.Sun;
int y = (int)Day.Fri;
Console.WriteLine("Sun = {0}", x);
Console.WriteLine("Fri = {0}", y);
//Enum을 사용하는게 더 직관적이다.
//Enum을 통한 문자열 출력
Console.WriteLine(Day.Sun);
Console.WriteLine(Day.Mon);
//일반 문자열 출력
Console.WriteLine("Sun");
Console.WriteLine("Mon");
//Enum 변수에 할당
Day dayEnum = Day.Fri;
Console.WriteLine(dayEnum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment