ArgumentExceptionExtensions Class
Provides ThrowNew extension methods for ArgumentException.
public static class ArgumentExceptionExtensionsRemarks
Each public constructor of the exception type has two methods, with the parameters of the constructor. Call them on the exception type, as in ArgumentException.ThrowNew(message).
The first method returns no value. Call it as a statement.
The second method has a type parameter, which is also its return type. Call it where the code needs an expression of that type.
See also
Methods
| Name | Description |
|---|---|
| ArgumentException.ThrowNew() | Throws a new ArgumentException. |
| ArgumentException.ThrowNew(string?) | Throws a new ArgumentException. |
| ArgumentException.ThrowNew(string?, Exception?) | Throws a new ArgumentException. |
| ArgumentException.ThrowNew(string?, string?) | Throws a new ArgumentException. |
| ArgumentException.ThrowNew(string?, string?, Exception?) | Throws a new ArgumentException. |
| ArgumentException.ThrowNew<T>() | Throws a new ArgumentException, where the code needs an expression of type T. |
| ArgumentException.ThrowNew<T>(string?) | Throws a new ArgumentException, where the code needs an expression of type T. |
| ArgumentException.ThrowNew<T>(string?, Exception?) | Throws a new ArgumentException, where the code needs an expression of type T. |
| ArgumentException.ThrowNew<T>(string?, string?) | Throws a new ArgumentException, where the code needs an expression of type T. |
| ArgumentException.ThrowNew<T>(string?, string?, Exception?) | Throws a new ArgumentException, where the code needs an expression of type T. |
ArgumentException.ThrowNew overloads
ArgumentException.ThrowNew()
Throws a new ArgumentException.
extension(ArgumentException)
{
public static void ThrowNew()
}ArgumentException.ThrowNew(string?)
Throws a new ArgumentException.
extension(ArgumentException)
{
public static void ThrowNew(string? message)
}Parameters
messagestring?- The error message that explains the reason for the exception.
ArgumentException.ThrowNew(string?, Exception?)
Throws a new ArgumentException.
extension(ArgumentException)
{
public static void ThrowNew(string? message, Exception? innerException)
}Parameters
messagestring?- The error message that explains the reason for the exception.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is not a null reference, the current exception is raised in acatchblock that handles the inner exception.
ArgumentException.ThrowNew(string?, string?)
Throws a new ArgumentException.
extension(ArgumentException)
{
public static void ThrowNew(string? message, string? paramName)
}ArgumentException.ThrowNew(string?, string?, Exception?)
Throws a new ArgumentException.
extension(ArgumentException)
{
public static void ThrowNew(string? message, string? paramName, Exception? innerException)
}Parameters
messagestring?- The error message that explains the reason for the exception.
paramNamestring?- The name of the parameter that caused the current exception.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is not a null reference, the current exception is raised in acatchblock that handles the inner exception.
ArgumentException.ThrowNew<T>()
Throws a new ArgumentException, where the code needs an expression of type T.
extension(ArgumentException)
{
public static T ThrowNew<T>()
}Type parameters
T- The type of the expression.
Returns
T This method does not return.
ArgumentException.ThrowNew<T>(string?)
Throws a new ArgumentException, where the code needs an expression of type T.
extension(ArgumentException)
{
public static T ThrowNew<T>(string? message)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- The error message that explains the reason for the exception.
Returns
T This method does not return.
ArgumentException.ThrowNew<T>(string?, Exception?)
Throws a new ArgumentException, where the code needs an expression of type T.
extension(ArgumentException)
{
public static T ThrowNew<T>(string? message, Exception? innerException)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- The error message that explains the reason for the exception.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is not a null reference, the current exception is raised in acatchblock that handles the inner exception.
Returns
T This method does not return.
ArgumentException.ThrowNew<T>(string?, string?)
Throws a new ArgumentException, where the code needs an expression of type T.
extension(ArgumentException)
{
public static T ThrowNew<T>(string? message, string? paramName)
}ArgumentException.ThrowNew<T>(string?, string?, Exception?)
Throws a new ArgumentException, where the code needs an expression of type T.
extension(ArgumentException)
{
public static T ThrowNew<T>(string? message, string? paramName, Exception? innerException)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- The error message that explains the reason for the exception.
paramNamestring?- The name of the parameter that caused the current exception.
innerExceptionException?- The exception that is the cause of the current exception. If the
innerExceptionparameter is not a null reference, the current exception is raised in acatchblock that handles the inner exception.
Returns
T This method does not return.