Редагувати

Поділитися через


Array.CreateInstanceFromArrayType Method

Definition

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

Creates a multidimensional Array of the specified Type and dimension lengths, with zero-based indexing.

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

arrayType is null.

-or-

lengths is null.

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

length
Int32

The size of the Array to create.

Returns

A new one-dimensional Array of the specified Type with the specified length.

Exceptions

arrayType is null.

length is negative.

arrayType is not an array type.

-or-

arrayType is not one-dimensional array.

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

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

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.

Applies to