Array.CreateInstanceFromArrayType Method (System) (original) (raw)
Source:
Creates a multidimensional Array of the specified Type and dimension lengths, with the specified lower bounds.
public:
static Array ^ CreateInstanceFromArrayType(Type ^ arrayType, cli::array <int> ^ lengths, cli::array <int> ^ lowerBounds);
public static Array CreateInstanceFromArrayType(Type arrayType, int[] lengths, int[] lowerBounds);
static member CreateInstanceFromArrayType : Type * int[] * int[] -> Array
Public Shared Function CreateInstanceFromArrayType (arrayType As Type, lengths As Integer(), lowerBounds As Integer()) As Array
Parameters
arrayType
The type of the array (not of the array element type).
lengths
Int32[]
The dimension lengths, specified in an array of 32-bit integers.
lowerBounds
Int32[]
A one-dimensional array that contains the lower bound (starting index) of each dimension of the Array to create.
Returns
A new multidimensional Array of the specified Type with the specified length and lower bound for each dimension.
Exceptions
arrayType
is null
.
-or-
lengths
is null
.
-or-
lowerBounds
is null
.
The lengths
and lowerBounds
arrays do not contain the same number of elements.
-or-
The lengths array is empty.
-or-
arrayType
is not an array type.
-or-
arrayType
rank does not match lengths
length.
Any value in lengths
is less than zero.
Native AOT: any value in lowerBounds
is different than zero.
Remarks
When the array type is readily available, this method should be preferred over CreateInstance(Type, Int32[], Int32[]), as it has better performance and it is AOT-friendly.