Table of Contents

Class ArgumentNullException

Namespace
System
Assembly
mscorlib.dll

The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

public class ArgumentNullException : ArgumentException
Inheritance
ArgumentNullException
Inherited Members
Extension Methods

Constructors

ArgumentNullException()

Initializes a new instance of the ArgumentNullException class.

public ArgumentNullException()

ArgumentNullException(string?)

Initializes a new instance of the ArgumentNullException class with the name of the parameter that causes this exception.

public ArgumentNullException(string? paramName)

Parameters

paramName string

The name of the parameter that caused the exception.

ArgumentNullException(string?, Exception?)

Initializes a new instance of the ArgumentNullException class with a specified error message and the exception that is the cause of this exception.

public ArgumentNullException(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.

ArgumentNullException(string?, string?)

Initializes an instance of the ArgumentNullException class with a specified error message and the name of the parameter that causes this exception.

public ArgumentNullException(string? paramName, string? message)

Parameters

paramName string

The name of the parameter that caused the exception.

message string

The error message that explains the reason for this exception.

Methods

ThrowIfNull(object?, string?)

Throws an ArgumentNullException if argument is null.

public static void ThrowIfNull(object? argument, string? paramName = null)

Parameters

argument object

The reference type argument to validate as non-null.

paramName string

The name of the parameter with which argument corresponds.