switch 문에 대한 옵션으로 enum을 사용하고 있습니다. 문제는 사용자가 유효하지 않은 옵션을 입력하여 프로그램이 충돌 한 경우입니다. 기본값을 사용하도록 추가해야하는 항목은 무엇입니까?enum 및 switch 문 사용 C#
열거 프로그램 충돌에서 주요 내 switch 문
string volString = Console.ReadLine();
Options options = (Options)Enum.Parse(typeof(Options), volString);
// this is the line that is giving me the runtime error. Since other options are not found
내 열거 클래스
public enum Options : byte
{
Display = 1,
Add,
Toggle,
Max,
Mean,
Medium,
Exit
}
. 텍스트가 당신의 열거로 변환 할 수있는 경우
switch (options)
{
case Options.Display: //dispaly regular time
case Options.Toggle://toggle
default:
Console.WriteLine("entry blah blah");
break;
런타임 오류의 어떤 종류를 얻을 수 있습니까? – dasblinkenlight