ArrayCreateInstance Method (Type, Int32) |
Creates a multidimensional
Array of the specified
Type and dimension lengths, with zero-based indexing. The dimension lengths are specified in an array of 32-bit integers.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static Array CreateInstance(
Type elementType,
params int[] lengths
)
Parameters
- elementType
- Type: SystemType
The Type of the Array to create. - lengths
- Type: SystemInt32
An array of 32-bit integers that represent the size of each dimension of the Array to create.
Return Value
Type:
ArrayA new multidimensional
Array of the specified
Type with the specified length for each dimension, using zero-based indexing.
Exceptions Exception | Condition |
---|
ArgumentNullException | elementType is null.-or-lengths is null. |
ArgumentException | elementType is not a valid Type.-or-The lengths array contains less than one element. |
NotSupportedException | elementType is not supported. For example, Void is not supported. -or-elementType is an open generic type. |
ArgumentOutOfRangeException | Any value in lengths is less than zero. |
See Also