Represents an exception that is thrown when a method is invoked and one of the arguments is not valid.
Object
Exception
SystemException
ArgumentException
[Visual Basic] Public Class ArgumentException Inherits SystemException [C#] public class ArgumentException : SystemException [C++] public __gc class ArgumentException : public SystemException [JScript] public class ArgumentException extends SystemException
The ArgumentException is the class that is thrown when a method is invoked and one of the arguments passed to the method does not meet the contract of the called method. Ideally, an instance of ArgumentException should carry a meaningful error message describing the invalid argument, as well as the range of expected values for the argument.
The primary subclasses of ArgumentException are ArgumentNullException and ArgumentOutOfRangeException. These subclasses should be used instead of ArgumentException except in the situations that neither are acceptable. For example, exceptions are thrown by:
Note that an InvalidOperationException should be used when the invocation fails, and either the call does not have arguments or the failure has nothing to do with the arguments. For examples when InvalidOperationException are thrown:
Namespace: System
Assembly: mscorlib.dll