This documentation is archived and is not being maintained.

11.10.2 Array-Creation Expressions

Visual Studio .NET 2003

An array-creation expression is used to create a new instance of an array type. If an array size initialization modifier is supplied, the resulting array type is derived by deleting each of the individual arguments from the array size initialization argument list. The value of each argument determines the upper bound of the corresponding dimension in the newly allocated array instance. If the array-element initializer in the expression is not empty, each argument in the argument list must be a constant, and the rank and dimension lengths specified by the expression list must match those of the array element initializer.

If an array size initialization modifier is not supplied, then the type name must be an array type and the array element initializer must be empty or the rank of the specified array type must match that of the array element initializer. The individual dimension lengths are inferred from the number of elements in each of the corresponding nesting levels of the array element initializer. If the array-element initializer is empty, the length of each dimension is zero.

An array instance's rank and length of each dimension are constant for the entire lifetime of the instance. In other words, it is not possible to change the rank of an existing array instance, nor is it possible to resize its dimensions. Elements of arrays created by array-creation expressions are always initialized to their default value.

ArrayCreationExpression ::=
   New TypeName [ ArraySizeInitializationModifier ]

See Also

11.10.1 Object-Creation Expressions | 11.10.3 Delegate-Creation Expressions | 11.10 New Expressions | New (Visual Basic Language Reference) | Using the New Keyword (Visual Basic Language Concepts)