Converting Strings to Enum Values DarkKaiser, 2008년 1월 30일2023년 9월 5일 public enum DaysOfWeek { Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7 } string CurrentDayString = "Sunday"; DaysOfWeek CurrentDay = DaysOfWeek.Monday; try { CurrentDay = (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), CurrentDayString); } catch { // Invalid enumeration value } switch (CurrentDay) { case DaysOfWeek.Saturday: case DaysOfWeek.Sunday: // What are you doing working on the weekend break; default: // Get back to work break; } C# enum