InvalidEnumArgumentException 클래스

정의

잘못된 열거형 값을 사용할 때 throw되는 예외입니다.

public ref class InvalidEnumArgumentException : ArgumentException
public class InvalidEnumArgumentException : ArgumentException
[System.Serializable]
public class InvalidEnumArgumentException : ArgumentException
type InvalidEnumArgumentException = class
    inherit ArgumentException
[<System.Serializable>]
type InvalidEnumArgumentException = class
    inherit ArgumentException
Public Class InvalidEnumArgumentException
Inherits ArgumentException
상속
InvalidEnumArgumentException
특성

예제

다음 코드 예제에서는 예외를 catch InvalidEnumArgumentException 하고 해당 콘텐츠를 해석하는 방법을 보여 있습니다. 이 예제에서는 메서드의 세 번째 인수로 캐스팅을 통해 잘못된 열거형 값(MessageBoxButtons)을 MessageBox.Show 전달하려고 시도합니다. 예외를 catch할 때 예제에서는 해당 오류 메시지, 잘못된 매개 변수, 스택 추적 및 예외의 원본을 가져옵니다.

try
{
   //Attempting to pass an invalid enum value (MessageBoxButtons) to the Show method
   MessageBoxButtons myButton = (MessageBoxButtons)123; // to fix use System::Windows::Forms::DialogResult::OK;

   MessageBox::Show( this,  "This is a message",  "This is the Caption", myButton );
}
catch ( InvalidEnumArgumentException^ invE ) 
{
   Console::WriteLine( invE->Message );
   Console::WriteLine( invE->ParamName );
   Console::WriteLine( invE->StackTrace );
   Console::WriteLine( invE->Source );
}
try 
{
// Attempts to pass an invalid enum value (MessageBoxButtons) to the Show method
    MessageBoxButtons myButton= (MessageBoxButtons) 123;
    MessageBox.Show("This is a message","This is the Caption",myButton);
}
catch(InvalidEnumArgumentException invE) 
{
    Console.WriteLine(invE.Message);
    Console.WriteLine(invE.ParamName);
    Console.WriteLine(invE.StackTrace);
    Console.WriteLine(invE.Source);
}
Try
    ' Attempts to pass an invalid enum value (MessageBoxButtons) to the Show method
    Dim myButton As MessageBoxButtons
    myButton = CType(123, MessageBoxButtons)
    MessageBox.Show("This is a message", "This is the Caption", myButton)
Catch invE As System.ComponentModel.InvalidEnumArgumentException
    Console.WriteLine(invE.Message)
    Console.WriteLine(invE.ParamName)
    Console.WriteLine(invE.StackTrace)
    Console.WriteLine(invE.Source)
End Try

설명

메서드에 잘못된 열거형 값을 전달하거나 속성을 설정할 때 이 예외가 throw됩니다.

생성자

InvalidEnumArgumentException()

메시지를 사용하지 않고 InvalidEnumArgumentException 클래스의 새 인스턴스를 초기화합니다.

InvalidEnumArgumentException(SerializationInfo, StreamingContext)

지정된 serialization 데이터와 컨텍스트를 사용하여 InvalidEnumArgumentException 클래스의 새 인스턴스를 초기화합니다.

InvalidEnumArgumentException(String)

지정된 메시지를 사용하여 InvalidEnumArgumentException 클래스의 새 인스턴스를 초기화합니다.

InvalidEnumArgumentException(String, Exception)

지정된 예외 및 자세한 설명을 사용하여 InvalidEnumArgumentException 클래스의 새 인스턴스를 초기화합니다.

InvalidEnumArgumentException(String, Int32, Type)

인수, 잘못된 값 및 열거형 클래스에서 생성된 메시지를 사용하여 InvalidEnumArgumentException 클래스의 새 인스턴스를 초기화합니다.

속성

Data

예외에 대한 사용자 정의 정보를 추가로 제공하는 키/값 쌍 컬렉션을 가져옵니다.

(다음에서 상속됨 Exception)
HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
HResult

특정 예외에 할당된 코드화된 숫자 값인 HRESULT를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
InnerException

현재 예외를 발생시킨 Exception 인스턴스를 가져옵니다.

(다음에서 상속됨 Exception)
Message

오류 메시지 및 매개 변수 이름을 가져오거나, 매개 변수 이름이 설정되지 않은 경우에는 오류 메시지만 가져옵니다.

(다음에서 상속됨 ArgumentException)
ParamName

이 예외를 발생시킨 매개 변수의 이름을 가져옵니다.

(다음에서 상속됨 ArgumentException)
Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
StackTrace

호출 스택의 직접 실행 프레임 문자열 표현을 가져옵니다.

(다음에서 상속됨 Exception)
TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.

(다음에서 상속됨 Exception)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetBaseException()

파생 클래스에서 재정의된 경우 하나 이상의 후속 예외의 근본 원인이 되는 Exception 을 반환합니다.

(다음에서 상속됨 Exception)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)

매개 변수 이름 및 추가 예외 정보를 사용하여 SerializationInfo 개체를 설정합니다.

(다음에서 상속됨 ArgumentException)
GetType()

현재 인스턴스의 런타임 형식을 가져옵니다.

(다음에서 상속됨 Exception)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 예외에 대한 문자열 표현을 만들고 반환합니다.

(다음에서 상속됨 Exception)

이벤트

SerializeObjectState
사용되지 않습니다.

예외에 대한 serialize된 데이터가 들어 있는 예외 상태 개체가 만들어지도록 예외가 serialize될 때 발생합니다.

(다음에서 상속됨 Exception)

적용 대상