다음을 통해 공유


ArgumentException 생성자

정의

ArgumentException 클래스의 새 인스턴스를 초기화합니다.

오버로드

Name Description
ArgumentException()

ArgumentException 클래스의 새 인스턴스를 초기화합니다.

ArgumentException(String)

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

ArgumentException(SerializationInfo, StreamingContext)
사용되지 않음.

직렬화된 데이터를 사용하여 클래스의 새 인스턴스를 ArgumentException 초기화합니다.

ArgumentException(String, Exception)

지정된 오류 메시지와 이 예외의 ArgumentException 원인인 내부 예외에 대한 참조를 사용하여 클래스의 새 인스턴스를 초기화합니다.

ArgumentException(String, String)

지정된 오류 메시지와 이 예외를 ArgumentException 발생시키는 매개 변수의 이름을 사용하여 클래스의 새 인스턴스를 초기화합니다.

ArgumentException(String, String, Exception)

지정된 오류 메시지, 매개 변수 이름 및 이 예외의 ArgumentException 원인인 내부 예외에 대한 참조를 사용하여 클래스의 새 인스턴스를 초기화합니다.

ArgumentException()

Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs

ArgumentException 클래스의 새 인스턴스를 초기화합니다.

public:
 ArgumentException();
public ArgumentException();
Public Sub New ()

설명

이 생성자는 "잘못된 인수가 지정되었습니다."와 같은 오류를 설명하는 시스템 제공 메시지로 새 인스턴스의 속성을 초기화 Message 합니다. 이 메시지는 현재 시스템 문화권을 고려합니다.

다음 표에서는 인스턴스 ArgumentException에 대한 초기 속성 값을 보여 줍니다.

재산 가치
InnerException Null 참조(Nothing Visual Basic의 경우)입니다.
Message 지역화된 오류 메시지 문자열입니다.

적용 대상

ArgumentException(String)

Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs

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

public:
 ArgumentException(System::String ^ message);
public ArgumentException(string message);
public ArgumentException(string? message);
new ArgumentException : string -> ArgumentException
Public Sub New (message As String)

매개 변수

message
String

예외의 이유를 설명하는 오류 메시지입니다.

설명

이 생성자는 "잘못된 인수가 지정되었습니다."와 같은 오류를 설명하는 시스템 제공 메시지로 새 인스턴스의 속성을 초기화 Message 합니다. 이 메시지는 현재 시스템 문화권을 고려합니다.

다음 표에서는 인스턴스 ArgumentException에 대한 초기 속성 값을 보여 줍니다.

재산 가치
InnerException Null 참조(Nothing Visual Basic의 경우)입니다.
Message 오류 메시지 문자열입니다.

적용 대상

ArgumentException(SerializationInfo, StreamingContext)

Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs

주의

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

직렬화된 데이터를 사용하여 클래스의 새 인스턴스를 ArgumentException 초기화합니다.

protected:
 ArgumentException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected ArgumentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected ArgumentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new ArgumentException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentException
new ArgumentException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> ArgumentException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

매개 변수

info
SerializationInfo

serialize된 개체 데이터를 보유하는 개체입니다.

context
StreamingContext

원본 또는 대상에 대한 컨텍스트 정보입니다.

특성

설명

이 생성자는 역직렬화 중에 호출되어 스트림을 통해 전송되는 예외 개체를 다시 구성합니다. 자세한 내용은 XML 및 SOAP Serialization을 참조하세요.

추가 정보

적용 대상

ArgumentException(String, Exception)

Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs

지정된 오류 메시지와 이 예외의 ArgumentException 원인인 내부 예외에 대한 참조를 사용하여 클래스의 새 인스턴스를 초기화합니다.

public:
 ArgumentException(System::String ^ message, Exception ^ innerException);
public ArgumentException(string message, Exception innerException);
public ArgumentException(string? message, Exception? innerException);
new ArgumentException : string * Exception -> ArgumentException
Public Sub New (message As String, innerException As Exception)

매개 변수

message
String

예외의 이유를 설명하는 오류 메시지입니다.

innerException
Exception

현재 예외의 원인인 예외입니다. 매개 변수가 innerException null 참조가 아니면 내부 예외를 catch 처리하는 블록에서 현재 예외가 발생합니다.

설명

이 생성자는 매개 변수 값을 사용하여 새 인스턴스의 속성을 초기화 Message 합니다 message . 매개 변수의 message 내용은 인간이 이해할 수 있도록 하기 위한 것입니다. 이 문자열이 현재 시스템 문화권에 맞게 지역화되었는지 확인하려면 이 생성자의 호출자가 필요합니다.

이전 예외의 직접적인 결과로 throw되는 예외에는 속성의 이전 예외에 대한 참조가 InnerException 포함되어야 합니다. 속성 생성 InnerException 자에 전달 되는 동일한 값을 반환 하거나 null 속성 생성자에 내부 예외 값을 제공 하지 않는 경우 InnerException .

다음 표에서는 인스턴스 ArgumentException에 대한 초기 속성 값을 보여 줍니다.

재산 가치
InnerException 내부 예외 참조입니다.
Message 지역화된 오류 메시지 문자열입니다.

추가 정보

적용 대상

ArgumentException(String, String)

Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs

지정된 오류 메시지와 이 예외를 ArgumentException 발생시키는 매개 변수의 이름을 사용하여 클래스의 새 인스턴스를 초기화합니다.

public:
 ArgumentException(System::String ^ message, System::String ^ paramName);
public ArgumentException(string message, string paramName);
public ArgumentException(string? message, string? paramName);
new ArgumentException : string * string -> ArgumentException
Public Sub New (message As String, paramName As String)

매개 변수

message
String

예외의 이유를 설명하는 오류 메시지입니다.

paramName
String

현재 예외를 발생시킨 매개 변수의 이름입니다.

예제

다음 코드 예제에서는 생성자를 호출 ArgumentException 하는 방법을 보여 줍니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 ArgumentException 일부입니다.

static int DivideByTwo(int num)
{
    // If num is an odd number, throw an ArgumentException.
    if ((num & 1) == 1)
        throw new ArgumentException("Number must be even", "num");

    // num is even, return half of its value.
    return num / 2;
}
let divideByTwo num =
    // If num is an odd number, raise an ArgumentException.
    if num % 2 = 1 then
        raise (ArgumentException("num", "Number must be even"))

    // num is even, return half of its value.
    num / 2;

설명

이 생성자는 매개 변수 값을 사용하여 새 인스턴스의 속성을 초기화 Message 합니다 message . 매개 변수의 message 내용은 인간이 이해할 수 있도록 하기 위한 것입니다. 이 문자열이 현재 시스템 문화권에 맞게 지역화되었는지 확인하려면 이 생성자의 호출자가 필요합니다.

이 생성자는 .를 ParamName 사용하여 paramName새 인스턴스의 속성을 초기화합니다. 콘텐츠 paramName 는 인간이 이해할 수 있도록 고안되었습니다.

다음 표에서는 인스턴스 ArgumentException에 대한 초기 속성 값을 보여 줍니다.

재산 가치
Message 오류 메시지 문자열입니다.
ParamName 매개 변수 이름 문자열입니다.

적용 대상

ArgumentException(String, String, Exception)

Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs
Source:
ArgumentException.cs

지정된 오류 메시지, 매개 변수 이름 및 이 예외의 ArgumentException 원인인 내부 예외에 대한 참조를 사용하여 클래스의 새 인스턴스를 초기화합니다.

public:
 ArgumentException(System::String ^ message, System::String ^ paramName, Exception ^ innerException);
public ArgumentException(string message, string paramName, Exception innerException);
public ArgumentException(string? message, string? paramName, Exception? innerException);
new ArgumentException : string * string * Exception -> ArgumentException
Public Sub New (message As String, paramName As String, innerException As Exception)

매개 변수

message
String

예외의 이유를 설명하는 오류 메시지입니다.

paramName
String

현재 예외를 발생시킨 매개 변수의 이름입니다.

innerException
Exception

현재 예외의 원인인 예외입니다. 매개 변수가 innerException null 참조가 아니면 내부 예외를 catch 처리하는 블록에서 현재 예외가 발생합니다.

설명

이 생성자는 매개 변수 값을 사용하여 새 인스턴스의 속성을 초기화 Message 합니다 message . 매개 변수의 message 내용은 인간이 이해할 수 있도록 하기 위한 것입니다. 이 문자열이 현재 시스템 문화권에 맞게 지역화되었는지 확인하려면 이 생성자의 호출자가 필요합니다.

이 생성자는 .를 ParamName 사용하여 paramName새 인스턴스의 속성을 초기화합니다. 콘텐츠 paramName 는 인간이 이해할 수 있도록 고안되었습니다.

이전 예외의 직접적인 결과로 throw되는 예외에는 속성의 이전 예외에 대한 참조가 InnerException 포함되어야 합니다. 속성 생성 InnerException 자에 전달 되는 동일한 값을 반환 하거나 null 속성 생성자에 내부 예외 값을 제공 하지 않는 경우 InnerException .

다음 표에서는 인스턴스 ArgumentException에 대한 초기 속성 값을 보여 줍니다.

재산 가치
InnerException 내부 예외 참조입니다.
Message 지역화된 오류 메시지 문자열입니다.
ParamName 매개 변수 이름 문자열입니다.

추가 정보

적용 대상