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.SystemException

Represents the error that occurs when an attempt is made to store an element of the wrong type in an array.

is thrown when the system cannot convert the element to the type declared for the array. This exception will not be thrown if the element can be converted to the type declared for the array. For example, an element of type can be stored in an array declared to store values, but an element of type cannot be stored in a array because conversion between these types is not supported.

This exception is thrown by the method if a widening conversion cannot be performed on the operand to convert it to the array type.

It is generally unnecessary for applications to throw this exception.

The following CIL instructions throw :

ldelem.<type>

ldelema

stelem.<type>

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

`using System; class ArrayTypeMisMatchExample { public static void Main() { string[] array1={"hello","world"}; int[] array2 = {1,2}; try { Array.Copy(array1,array2,2); } catch (ArrayTypeMismatchException e) { Console.WriteLine("Error: {0}",e); } } }`

The output is

Error: System.ArrayTypeMismatchException: Source array type cannot be assigned to destination array type.

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

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

at ArrayTypeMisMatchExample.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 "Source array type cannot be assigned to destination array type." This message takes into account the current system culture.

  The property is initialized to .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  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 . 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
  4.0.0.0
- Constructor
  To be added.
  To be added.
  To be added.
  To be added.
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Constructor
  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.
  An instance of that is the cause of the current exception. If is non-null, then the current exception was raised in a catch block handling .

  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.

  For information on inner exceptions, see .

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