Format | Assembly Format | Description |
---|---|---|
8D <T> newarr etype | Create a new array with elements of type etype. |
…, numElems → …, array
The newarr
instruction pushes a reference to a new zero-based, one-dimensional array whose elements are of type etype, a metadata token (a typeref
, typedef
or typespec
; see Partition II). numElems (of type native int
or int32
) specifies the number of elements in the array. Valid array indexes are 0 ≤ index < numElems. The elements of an array can be any type, including value types.
Zero-based, one-dimensional arrays of numbers are created using a metadata token referencing the appropriate value type (System.Int32
, etc.). Elements of the array are initialized to 0 of the appropriate type.
One-dimensional arrays that aren't zero-based and multidimensional arrays are created using newobj
rather than newarr
. More commonly, they are created using the methods of System.Array
class in the Base Framework.
System.OutOfMemoryException
is thrown if there is insufficient memory to satisfy the request.
System.OverflowException
is thrown if numElems is < 0
Correct CIL ensures that etype is a valid typeref
, typedef
or typespec
token.
numElems shall be of type native int
or int32
.