CodeArrayCreateExpression クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class CodeArrayCreateExpression Inherits CodeExpression
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeArrayCreateExpression : CodeExpression
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class CodeArrayCreateExpression : public CodeExpression

CodeArrayCreateExpression は、配列を作成するコード式を表すために使用できます。配列を作成する式では、要素の数を指定するか、または配列を初期化するために使用する式のリストを指定する必要があります。
ほとんどの配列は、宣言の直後に初期化できます。Initializers プロパティには、配列を初期化するために使用する式を設定できます。
CodeArrayCreateExpression によって作成が直接サポートされるのは、1 次元配列だけです。言語で配列内の配列を使用できる場合は、CodeArrayCreateExpression 内に CodeArrayCreateExpression を入れ子にして多次元配列を作成できます。配列の配列は、すべての言語でサポートされているわけではありません。ArraysOfArrays フラグを使用して Supports を呼び出すことで、入れ子になった配列のサポートを言語の ICodeGenerator が宣言しているかどうかをチェックできます。

CodeArrayCreateExpression を使用して、10 個のインデックスを持つ整数の配列を作成するコードを次に示します。
' 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];

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


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CodeArrayCreateExpression クラスのページへのリンク