Array.CreateInstance Method (Type, Int32, Int32, Int32)

 

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

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

static member CreateInstance : 
        elementType:Type *
        length1:int *
        length2:int *
        length3:int -> Array

Parameters

elementType
Type: System.Type

The Type of the Array to create.

length1
Type: System.Int32

The size of the first dimension of the Array to create.

length2
Type: System.Int32

The size of the second dimension of the Array to create.

length3
Type: System.Int32

The size of the third dimension of the Array to create.

Return Value

Type: System.Array

A new three-dimensional Array of the specified Type with the specified length for each dimension, using zero-based indexing.

Exception Condition
ArgumentNullException

elementType is null.

ArgumentException

elementType is not a valid Type.

NotSupportedException

elementType is not supported. For example, Void is not supported.

-or-

elementType is an open generic type.

ArgumentOutOfRangeException

length1 is less than zero.

-or-

length2 is less than zero.

-or-

length3 is less than zero.

Unlike most classes, Array provides the CreateInstance method, instead of public constructors, to allow for late bound access.

Reference-type elements are initialized to null. Value-type elements are initialized to zero.

This method is an O(n) operation, where n is the product of length1, length2, and length3.

The following code example shows how to create and initialize a three-dimensional Array.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: