Array.CreateInstanceFromArrayType Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateInstanceFromArrayType(Type, Int32[]) |
Creates a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing. |
CreateInstanceFromArrayType(Type, Int32) |
Creates a one-dimensional Array of the specified array type and length, with zero-based indexing. |
CreateInstanceFromArrayType(Type, Int32[], Int32[]) |
Creates a multidimensional Array of the specified Type and dimension lengths, with the specified lower bounds. |
CreateInstanceFromArrayType(Type, Int32[])
- Source:
- Array.cs
public:
static Array ^ CreateInstanceFromArrayType(Type ^ arrayType, ... cli::array <int> ^ lengths);
public static Array CreateInstanceFromArrayType (Type arrayType, params int[] lengths);
static member CreateInstanceFromArrayType : Type * int[] -> Array
Public Shared Function CreateInstanceFromArrayType (arrayType As Type, ParamArray lengths As Integer()) As Array
Parameters
- arrayType
- Type
The type of the array (not of the array element type).
- lengths
- Int32[]
The dimension lengths, specified in an array of 32-bit integers.
Returns
A new multidimensional Array of the specified Type with the specified length for each dimension, using zero-based indexing.
Exceptions
Any value in lengths
is less than zero.
The lengths array is empty.
-or-
arrayType
is not an array type.
-or-
arrayType
rank does not match lengths
length.
Remarks
When the array type is readily available, this method should be preferred over CreateInstance(Type, Int32[]), as it has better performance and it is AOT-friendly.
Applies to
CreateInstanceFromArrayType(Type, Int32)
- Source:
- Array.cs
Creates a one-dimensional Array of the specified array type and length, with zero-based indexing.
public:
static Array ^ CreateInstanceFromArrayType(Type ^ arrayType, int length);
public static Array CreateInstanceFromArrayType (Type arrayType, int length);
static member CreateInstanceFromArrayType : Type * int -> Array
Public Shared Function CreateInstanceFromArrayType (arrayType As Type, length As Integer) As Array
Parameters
- arrayType
- Type
The type of the array (not of the array element type).
Returns
A new one-dimensional Array of the specified Type with the specified length.
Exceptions
arrayType
is null
.
length
is negative.
Remarks
When the array type is readily available, this method should be preferred over CreateInstance(Type, Int32), as it has better performance and it is AOT-friendly.
Applies to
CreateInstanceFromArrayType(Type, Int32[], Int32[])
- Source:
- Array.cs
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
- Type
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
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.
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om