BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.ArgumentException

Represents the error that occurs when an argument passed to a method is invalid because it is outside the allowable range of values as specified by the method.

is thrown when a method is invoked and at least one of the arguments passed to the method is not and does not contain a valid value.

behaves identically to . It is provided so that application code can differentiate between exceptions caused by invalid arguments that are not , and exceptions caused by arguments. For errors caused by arguments, see .

The following example demonstrates an error that causes the class to throw a exception.

`using System; class ArgOutOfRangeExample { public static void Main() { int[] array1 = {0,0}; int[] array2 = {0,0}; try { Array.Copy(array1,array2,-1); } catch (ArgumentOutOfRangeException e) { Console.WriteLine("Error: {0}",e); } } }`

The output is

Error: System.ArgumentOutOfRangeException: Non-negative number required.

Parameter name: length

at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)

at ArgOutOfRangeExample.Main()

- Constructor

  Constructs and initializes a new instance of the class.

  This constructor initializes the property of the new instance to a system-supplied message that describes the error, such as "Non-negative number required." This message takes into account the current system culture.

  The and properties are initialized to .

  0
  1.0.5000.0
  2.0.0.0
- Constructor
  A that contains the name of the parameter that caused the current exception. The content of is intended to be understood by humans.

  Constructs and initializes a new instance of the class.

  This constructor initializes the property of the new instance using . The property is initialized to the system-supplied message provided by the constructor that takes no arguments.

  The property is initialized to .

  0
  1.0.5000.0
  2.0.0.0
- Constructor
  To be added.
  To be added.
  To be added.
  To be added.
  1.0.5000.0
  2.0.0.0
- Constructor
  To be added.
  To be added.
  To be added.
  To be added.
  2.0.0.0
- Constructor
  A that contains the name of the parameter that caused the current exception. The content of is intended to be understood by humans.
  A that describes the error. The content of is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

  Constructs and initializes a new instance of the class.

  This constructor initializes the property of the new instance using , and the property using . If is , the property is initialized to the system-supplied message provided by the constructor that takes no arguments.

  The property is initialized to .

  0
  1.0.5000.0
  2.0.0.0
- Constructor
  A that contains the name of the parameter that caused the current exception. The content of is intended to be understood by humans.
  The value of the argument that caused the current exception.
  A that describes the error. The content of is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

  Constructs and initializes a new instance of the class.

  This constructor initializes the property of the new instance using , the property using , and the property using . If is , the property is initialized to the system-supplied message provided by the constructor that takes no arguments.

  The parameter contains the invalid argument that was passed to the method. Use the property to retrieve the name of the parameter used to pass .

  0
  1.0.5000.0
  2.0.0.0
- Property
  System.Object

  Gets the value of the parameter that caused the current exception.

  A that contains the value of the parameter that caused the current exception, or if no value was specified to the constructor for the current instance.

  This property is read-only.

  The property returns the same value as was passed into the constructor.

  Override the property to customize the content or format of the value.

  Use this property to retrieve the invalid argument.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Void `` `` To be added. To be added. To be added. To be added. 1.0.5000.0 2.0.0.0
- Property
  System.String

  Gets the error message that explains the reason for the exception.

  A containing the error message. The error message should describe the expected values of the parameter that causes this exception.

  This property is read-only.

  1.0.5000.0
  2.0.0.0
0 System.Runtime.InteropServices.ComVisible(true)