Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Creates a one-dimensional Array of the specified Type and length, with zero-based indexing.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Shared Function CreateInstance ( _
elementType As Type, _
length As Integer _
) As Array
public static Array CreateInstance(
Type elementType,
int length
)
public:
static Array^ CreateInstance(
Type^ elementType,
int length
)
static member CreateInstance :
elementType:Type *
length:int -> Array
public static function CreateInstance(
elementType : Type,
length : int
) : Array
Parameters
- elementType
Type: System. . :: . .Type
The Type of the Array to create.
- length
Type: System. . :: . .Int32
The size of the Array to create.
Return Value
Type: System. . :: . .Array
A new one-dimensional Array of the specified Type with the specified length, using zero-based indexing.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | elementType is null Nothing nullptr unit a null reference (Nothing in Visual Basic) . |
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 | length is less than zero. |
Remarks
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 Nothing nullptr unit a null reference (Nothing in Visual Basic) . Value-type elements are initialized to zero.
This method is an O(n) operation, where n is length.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.