Freigeben über


CodeArrayCreateExpression-Klasse

Stellt einen Ausdruck dar, der ein Array erstellt.

Namespace: System.CodeDom
Assembly: System (in system.dll)

Syntax

'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeArrayCreateExpression
    Inherits CodeExpression
'Usage
Dim instance As CodeArrayCreateExpression
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeArrayCreateExpression : CodeExpression
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeArrayCreateExpression : public CodeExpression
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeArrayCreateExpression extends CodeExpression
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeArrayCreateExpression extends CodeExpression

Hinweise

Mit CodeArrayCreateExpression kann ein Codeausdruck dargestellt werden, der ein Array erstellt. Für Ausdrücke, mit denen ein Array erstellt wird, muss entweder eine Anzahl von Elementen oder eine Liste von Ausdrücken für die Initialisierung des Arrays angegeben werden.

Die meisten Arrays können unmittelbar nach der Deklaration initialisiert werden. Die Initializers-Eigenschaft kann auf den Ausdruck festgelegt werden, mit dem das Array initialisiert werden soll.

CodeArrayCreateExpression unterstützt das Erstellen von eindimensionalen Arrays nur direkt. Wenn eine Sprache Arrays innerhalb von Arrays zulässt, können mehrdimensionale Arrays durch Schachtelung einer CodeArrayCreateExpression in einer CodeArrayCreateExpression erstellt werden. Nicht alle Sprachen unterstützen Arrays von Arrays. Sie können überprüfen, ob ein ICodeGenerator geschachtelte Arrays für eine Sprache unterstützt, indem Sie Supports mit dem ArraysOfArrays-Flag aufrufen.

Beispiel

Im folgenden Code wird zum Erstellen eines Arrays von ganzen Zahlen mit 10 Indizes eine CodeArrayCreateExpression verwendet.

' 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) {}
// 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];
// Create an initialization expression for a new array of type Int32 with 10 indices
CodeArrayCreateExpression^ ca1 = gcnew CodeArrayCreateExpression( "System.Int32",10 );

// Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression
CodeVariableDeclarationStatement^ cv1 = gcnew CodeVariableDeclarationStatement( "System.Int32[]","x",ca1 );

// A C# code generator produces the following source code for the preceeding example code:
// int[] x = new int[10];
// 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 VJ# code generator produces the following source code for the 
// preceeding example code:
// int x[] = new int[10];

Vererbungshierarchie

System.Object
   System.CodeDom.CodeObject
     System.CodeDom.CodeExpression
      System.CodeDom.CodeArrayCreateExpression

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

CodeArrayCreateExpression-Member
System.CodeDom-Namespace
CodeObjectCreateExpression