CodeArrayCreateExpression 類別

定義

表示建立陣列的運算式。

public ref class CodeArrayCreateExpression : System::CodeDom::CodeExpression
public class CodeArrayCreateExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeArrayCreateExpression : System.CodeDom.CodeExpression
type CodeArrayCreateExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeArrayCreateExpression = class
    inherit CodeExpression
Public Class CodeArrayCreateExpression
Inherits CodeExpression
繼承
CodeArrayCreateExpression
屬性

範例

下列程式代碼會使用 CodeArrayCreateExpression 來建立具有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 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
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) {}

備註

CodeArrayCreateExpression 可用來表示建立數位件的程式代碼表達式。 建立陣列的運算式應該指定一些專案,或用來初始化陣列的運算式清單。

大部分的陣列都可以緊接在宣告之後初始化。 屬性 Initializers 可以設定為表示式,以用來初始化數位。

CodeArrayCreateExpression僅支援建立單一維度陣列。 如果語言允許陣列陣列,就可以在內CodeArrayCreateExpressionCodeArrayCreateExpression狀建立陣列。 並非所有語言都支持陣列陣列。 您可以使用 旗標呼叫 SupportsArraysOfArrays ,檢查 語言是否ICodeGenerator宣告對巢狀陣列的支援。

建構函式

CodeArrayCreateExpression()

初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(CodeTypeReference, CodeExpression)

使用指定的陣列資料型別和指示陣列的索引數目的程式碼運算式,初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(CodeTypeReference, CodeExpression[])

使用指定的陣列資料型別和初始化運算式,初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(CodeTypeReference, Int32)

使用指定的陣列資料型別和陣列的索引數目,初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(String, CodeExpression)

使用指定的陣列資料型別名稱和指示陣列的索引數目的程式碼運算式,初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(String, CodeExpression[])

使用指定的陣列資料型別名稱和初始設定式,初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(String, Int32)

使用指定的陣列資料型別名稱和陣列的索引數目,初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(Type, CodeExpression)

使用指定的陣列資料型別和指示陣列的索引數目的程式碼運算式,初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(Type, CodeExpression[])

使用指定的陣列資料型別和初始設定式來初始化 CodeArrayCreateExpression 類別的新執行個體。

CodeArrayCreateExpression(Type, Int32)

使用指定的陣列資料型別和陣列的索引數目,初始化 CodeArrayCreateExpression 類別的新執行個體。

屬性

CreateType

取得或設定要建立陣列的型別。

Initializers

取得用來初始化陣列的初始設定式。

Size

取得或設定陣列的索引數目。

SizeExpression

取得或設定指示陣列大小的運算式。

UserData

取得目前物件的使用者可定義資料。

(繼承來源 CodeObject)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱