Created
May 2, 2018 13:43
-
-
Save momoci99/6eb06ebe6d9801ed90de627ae14d751d to your computer and use it in GitHub Desktop.
Enum 코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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