ArgumentNullExceptionExtensions Class
Provides ThrowNew extension methods for ArgumentNullException.
public static class ArgumentNullExceptionExtensionsRemarks
Each public constructor of the exception type has two methods, with the parameters of the constructor. Call them on the exception type, as in ArgumentNullException.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
| Name | Description |
|---|---|
| ArgumentNullException.ThrowNew() | Throws a new ArgumentNullException. |
| ArgumentNullException.ThrowNew(string?) | Throws a new ArgumentNullException. |
| ArgumentNullException.ThrowNew(string?, Exception?) | Throws a new ArgumentNullException. |
| ArgumentNullException.ThrowNew(string?, string?) | Throws a new ArgumentNullException. |
| ArgumentNullException.ThrowNew<T>() | Throws a new ArgumentNullException, where the code needs an expression of type T. |
| ArgumentNullException.ThrowNew<T>(string?) | Throws a new ArgumentNullException, where the code needs an expression of type T. |
| ArgumentNullException.ThrowNew<T>(string?, Exception?) | Throws a new ArgumentNullException, where the code needs an expression of type T. |
| ArgumentNullException.ThrowNew<T>(string?, string?) | Throws a new ArgumentNullException, where the code needs an expression of type T. |
ArgumentNullException.ThrowNew overloads
ArgumentNullException.ThrowNew()
Throws a new ArgumentNullException.
extension(ArgumentNullException)
{
public static void ThrowNew()
}ArgumentNullException.ThrowNew(string?)
Throws a new ArgumentNullException.
extension(ArgumentNullException)
{
public static void ThrowNew(string? paramName)
}Parameters
paramNamestring?- The name of the parameter that caused the exception.
ArgumentNullException.ThrowNew(string?, Exception?)
Throws a new ArgumentNullException.
extension(ArgumentNullException)
{
public static void ThrowNew(string? message, Exception? innerException)
}Parameters
messagestring?- The error message that explains the reason for this exception.
innerExceptionException?- The exception that is the cause of the current exception, or a null reference (
Nothingin Visual Basic) if no inner exception is specified.
ArgumentNullException.ThrowNew(string?, string?)
Throws a new ArgumentNullException.
extension(ArgumentNullException)
{
public static void ThrowNew(string? paramName, string? message)
}ArgumentNullException.ThrowNew<T>()
Throws a new ArgumentNullException, where the code needs an expression of type T.
extension(ArgumentNullException)
{
public static T ThrowNew<T>()
}Type parameters
T- The type of the expression.
Returns
T This method does not return.
ArgumentNullException.ThrowNew<T>(string?)
Throws a new ArgumentNullException, where the code needs an expression of type T.
extension(ArgumentNullException)
{
public static T ThrowNew<T>(string? paramName)
}Type parameters
T- The type of the expression.
Parameters
paramNamestring?- The name of the parameter that caused the exception.
Returns
T This method does not return.
ArgumentNullException.ThrowNew<T>(string?, Exception?)
Throws a new ArgumentNullException, where the code needs an expression of type T.
extension(ArgumentNullException)
{
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 this exception.
innerExceptionException?- The exception that is the cause of the current exception, or a null reference (
Nothingin Visual Basic) if no inner exception is specified.
Returns
T This method does not return.
ArgumentNullException.ThrowNew<T>(string?, string?)
Throws a new ArgumentNullException, where the code needs an expression of type T.
extension(ArgumentNullException)
{
public static T ThrowNew<T>(string? paramName, string? message)
}