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 4.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 System.Runtime.InteropServices.ComVisible(true)

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()

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

is used extensively by:

Classes in the and namespaces.

The class.

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

uses the HRESULT COR_E_ARGUMENTOUTOFRANGE, which has the value 0x80131502.

For a list of initial property values for an instance of , see the constructors.

The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

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

  The following table shows the initial property values for an instance of .

  Property

  Value

  A null reference (Nothing in Visual Basic).

  The localized error message string.

  Initializes a new instance of the class.

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

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

  This constructor initializes the property of the new instance using the parameter. The content of is intended to be understood by humans.

  The following table shows the initial property values for an instance of .

  Property

  Value

  A null reference (Nothing in Visual Basic).

  The empty string ("").

  The parameter name string.

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

  The name of the parameter that causes this exception.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. For more information, see XML and Soap Serialization.

  Initializes a new instance of the class with serialized data.

  The object that holds the serialized object data.
  An object that describes the source or destination of the serialized data.
- Constructor
  2.0.0.0
  4.0.0.0
  To be added.

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

  The error message that explains the reason for this 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.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor initializes the property of the new instance using the value of the parameter. The content of the parameter 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.

  This constructor initializes the property of the new instance using the parameter. The content of is intended to be understood by humans.

  The following table shows the initial property values for an instance of .

  Property

  Value

  null.

  The error message string.

  The parameter name string.

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

  The name of the parameter that caused the exception.
  The message that describes the error.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  This constructor initializes the property of the new instance using the parameter, the property using the parameter, and the property using the parameter. The content of the and parameters is intended to be understood by humans. The caller of this constructor is required to ensure that these strings have been localized for the current system culture.

  The parameter is not used within the .NET Framework class library. However, the property is provided so that applications can use the available argument value.

  The parameter contains an invalid value that is passed to the method and causes this exception to be thrown. This value is stored in the property and its string representation is appended to the message string held in the property.

  The following table shows the initial property values for an instance of .

  Property

  Value

  The argument value.

  The null reference (Nothing in Visual Basic).

  The error message string.

  The parameter name string.

  Initializes a new instance of the class with the parameter name, the value of the argument, and a specified error message.

  The name of the parameter that caused the exception.
  The value of the argument that causes this exception.
  The message that describes the error.
  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object

  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.

  Use this property to retrieve the invalid argument.

  The ActualValue property returns the same value that was passed to the constructor, or null if no value was supplied.

  The property is assigned a value at the time of object construction. If the property value is not null, a string representation of the value is appended to the message string held by the property.

  The property is not used within the .NET Framework class library. It carries a null value in all the objects thrown by the .NET Framework class library. The property is provided so that applications can use the available argument value.

  This property is read-only and should be overridden only to customize the content or format of the value.

  Gets the argument value that causes this exception.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` ``

  sets a object with all the exception object data targeted for serialization. During deserialization, the exception object is reconstituted from the transmitted over the stream.

  For more information, see .

  Sets the object with the invalid argument value and additional exception information.

  The object that holds the serialized object data. An object that describes the source or destination of the serialized data.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

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

  This property overrides .

  The error message should describe the expected values of the parameter that causes this exception. The error message should be localized.

  Gets the error message and the string representation of the invalid argument value, or only the error message if the argument value is null.

0