NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

10.6.2 Array creation expressions

An array creation expression is used to create a new instance of an array type. There are two forms of array creation expressions: one specifies a non-array type name and a list of expressions in parenthesis, the other specifies just an array type name.

An array creation expression of first form allocates an array instance of the type that results from deleting each of the individual arguments from the argument list. The type may not be an array type, and each argument in the argument list must be implicitly convertible to the type Integer and may not be a named argument. The value of each argument determines the length 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.

In an array creation expression of the second form, 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, then the length of each dimension is zero.

At runtime, the argument list (if any) is evaluated first and then the array element initializer. The result of evaluating an array creation expression is a reference to the newly allocated array instance. The type of the result is an array type whose 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 ( ArgumentList ) ArrayElementInitializer |
 New ArrayTypeName ArrayElementInitializer