CodeArrayCreateExpression Class
Represents an expression that creates an array.
For a list of all members of this type, see CodeArrayCreateExpression Members.
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeExpression
System.CodeDom.CodeArrayCreateExpression
[Visual Basic] <Serializable> <ClassInterface(ClassInterfaceType.AutoDispatch)> <ComVisible(True)> Public Class CodeArrayCreateExpression Inherits CodeExpression [C#] [Serializable] [ClassInterface(ClassInterfaceType.AutoDispatch)] [ComVisible(true)] public class CodeArrayCreateExpression : CodeExpression [C++] [Serializable] [ClassInterface(ClassInterfaceType::AutoDispatch)] [ComVisible(true)] public __gc class CodeArrayCreateExpression : public CodeExpression [JScript] public Serializable ClassInterface(ClassInterfaceType.AutoDispatch) ComVisible(true) class CodeArrayCreateExpression extends CodeExpression
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
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 within arrays, it is possible to create multi-dimensional arrays 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.
Example
[Visual Basic, C#, C++] The following code uses a CodeArrayCreateExpression to create an array of integers with 10 indexes.
[Visual Basic] ' 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) {} [C#] // Create an initialization expression for a new array of type Int32 with 10 indices CodeArrayCreateExpression ca1 = new CodeArrayCreateExpression("System.Int32", 10); // Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression CodeVariableDeclarationStatement cv1 = new CodeVariableDeclarationStatement("System.Int32[]", "x", ca1); // A C# code generator produces the following source code for the preceeding example code: // int[] x = new int[10]; [C++] // Create an initialization expression for a new array of type Int32 with 10 indices CodeArrayCreateExpression* ca1 = new CodeArrayCreateExpression(S"System.Int32", 10); // Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression CodeVariableDeclarationStatement* cv1 = new CodeVariableDeclarationStatement(S"System.Int32[]", S"x", ca1); // A C# code generator produces the following source code for the preceeding example code: // int[] x = new int[10];
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.CodeDom
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
See Also
CodeArrayCreateExpression Members | System.CodeDom Namespace | CodeObjectCreateExpression