CodeArrayCreateExpression Class
Represents an expression that creates an array.
Assembly: System (in System.dll)
CodeArrayCreateExpression can be used to represent a code expression that creates an array. Expressions that create an array should specify either a number of elements, or a list of expressions to use to initialize the array.
Most arrays can be initialized immediately following declaration. The Initializers property can be set to the expression to use to initialize the array.
A CodeArrayCreateExpression only directly supports creating single-dimension arrays. If a language allows arrays of arrays, it is possible to create them by nesting a CodeArrayCreateExpression within a CodeArrayCreateExpression. Not all languages support arrays of arrays. You can check whether an ICodeGenerator for a language declares support for nested arrays by calling Supports with the ArraysOfArrays flag.
The following code uses a CodeArrayCreateExpression to create an array of integers with 10 indexes.
' Create an initialization expression for a new array of type Int32 with 10 indices Dim ca1 As New CodeArrayCreateExpression("System.Int32", 10) ' Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression Dim cv1 As New CodeVariableDeclarationStatement("System.Int32[]", "x", ca1) ' A Visual Basic code generator produces the following source code for the preceeding example code: ' Dim x() As Integer = New Integer(9) {}
System.CodeDom.CodeObject
System.CodeDom.CodeExpression
System.CodeDom.CodeArrayCreateExpression
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.