ArgumentOutOfRangeExceptionExtensions Class

Provides ThrowNew extension methods for ArgumentOutOfRangeException.

public static class ArgumentOutOfRangeExceptionExtensions

Remarks

Each public constructor of the exception type has two methods, with the parameters of the constructor. Call them on the exception type, as in ArgumentOutOfRangeException.ThrowNew(paramName).

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

NameDescription
ArgumentOutOfRangeException.ThrowNew()Throws a new ArgumentOutOfRangeException.
ArgumentOutOfRangeException.ThrowNew(string?)Throws a new ArgumentOutOfRangeException.
ArgumentOutOfRangeException.ThrowNew(string?, Exception?)Throws a new ArgumentOutOfRangeException.
ArgumentOutOfRangeException.ThrowNew(string?, object?, string?)Throws a new ArgumentOutOfRangeException.
ArgumentOutOfRangeException.ThrowNew(string?, string?)Throws a new ArgumentOutOfRangeException.
ArgumentOutOfRangeException.ThrowNew<T>()Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.
ArgumentOutOfRangeException.ThrowNew<T>(string?)Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.
ArgumentOutOfRangeException.ThrowNew<T>(string?, Exception?)Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.
ArgumentOutOfRangeException.ThrowNew<T>(string?, object?, string?)Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.
ArgumentOutOfRangeException.ThrowNew<T>(string?, string?)Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.

ArgumentOutOfRangeException.ThrowNew overloads

ArgumentOutOfRangeException.ThrowNew()

extension(ArgumentOutOfRangeException)
{
    public static void ThrowNew()
}

ArgumentOutOfRangeException.ThrowNew(string?)

extension(ArgumentOutOfRangeException)
{
    public static void ThrowNew(string? paramName)
}
Parameters
paramName string?
The name of the parameter that causes this exception.

ArgumentOutOfRangeException.ThrowNew(string?, Exception?)

extension(ArgumentOutOfRangeException)
{
    public static void ThrowNew(string? message, Exception? innerException)
}
Parameters
message string?
The error message that explains the reason for this exception.
innerException Exception?
The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.

ArgumentOutOfRangeException.ThrowNew(string?, object?, string?)

extension(ArgumentOutOfRangeException)
{
    public static void ThrowNew(string? paramName, object? actualValue, string? message)
}
Parameters
paramName string?
The name of the parameter that caused the exception.
actualValue object?
The value of the argument that causes this exception.
message string?
The message that describes the error.

ArgumentOutOfRangeException.ThrowNew(string?, string?)

extension(ArgumentOutOfRangeException)
{
    public static void ThrowNew(string? paramName, string? message)
}
Parameters
paramName string?
The name of the parameter that caused the exception.
message string?
The message that describes the error.

ArgumentOutOfRangeException.ThrowNew<T>()

Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.

extension(ArgumentOutOfRangeException)
{
    public static T ThrowNew<T>()
}
Type parameters
T
The type of the expression.
Returns

T This method does not return.

ArgumentOutOfRangeException.ThrowNew<T>(string?)

Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.

extension(ArgumentOutOfRangeException)
{
    public static T ThrowNew<T>(string? paramName)
}
Type parameters
T
The type of the expression.
Parameters
paramName string?
The name of the parameter that causes this exception.
Returns

T This method does not return.

ArgumentOutOfRangeException.ThrowNew<T>(string?, Exception?)

Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.

extension(ArgumentOutOfRangeException)
{
    public static T ThrowNew<T>(string? message, Exception? innerException)
}
Type parameters
T
The type of the expression.
Parameters
message string?
The error message that explains the reason for this exception.
innerException Exception?
The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
Returns

T This method does not return.

ArgumentOutOfRangeException.ThrowNew<T>(string?, object?, string?)

Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.

extension(ArgumentOutOfRangeException)
{
    public static T ThrowNew<T>(string? paramName, object? actualValue, string? message)
}
Type parameters
T
The type of the expression.
Parameters
paramName string?
The name of the parameter that caused the exception.
actualValue object?
The value of the argument that causes this exception.
message string?
The message that describes the error.
Returns

T This method does not return.

ArgumentOutOfRangeException.ThrowNew<T>(string?, string?)

Throws a new ArgumentOutOfRangeException, where the code needs an expression of type T.

extension(ArgumentOutOfRangeException)
{
    public static T ThrowNew<T>(string? paramName, string? message)
}
Type parameters
T
The type of the expression.
Parameters
paramName string?
The name of the parameter that caused the exception.
message string?
The message that describes the error.
Returns

T This method does not return.