CodeArrayCreateExpression CodeArrayCreateExpression CodeArrayCreateExpression CodeArrayCreateExpression Class

定義

表示建立陣列的運算式。Represents an expression that creates an array.

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

範例

下列程式碼會使用CodeArrayCreateExpression來建立具有10個索引的整數陣列。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
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可以用來代表建立陣列的程式碼運算式。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. Initializers屬性可以設定為要用來初始化陣列的運算式。The Initializers property can be set to the expression to use to initialize the array.

CodeArrayCreateExpression僅直接支援建立單一維度陣列。A CodeArrayCreateExpression only directly supports creating single-dimension arrays. 如果語言允許陣列的陣列, 可以藉由CodeArrayCreateExpression CodeArrayCreateExpression在中嵌套來建立它們。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. 您可以使用ICodeGenerator Supports 旗標呼叫,以檢查語言的是否宣告對嵌套陣列的支援。ArraysOfArraysYou can check whether an ICodeGenerator for a language declares support for nested arrays by calling Supports with the ArraysOfArrays flag.

建構函式

CodeArrayCreateExpression() CodeArrayCreateExpression() CodeArrayCreateExpression() CodeArrayCreateExpression()

初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class.

CodeArrayCreateExpression(CodeTypeReference, CodeExpression) CodeArrayCreateExpression(CodeTypeReference, CodeExpression) CodeArrayCreateExpression(CodeTypeReference, CodeExpression) CodeArrayCreateExpression(CodeTypeReference, CodeExpression)

使用指定的陣列資料型別和指示陣列的索引數目的程式碼運算式,初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and code expression indicating the number of indexes for the array.

CodeArrayCreateExpression(CodeTypeReference, CodeExpression[]) CodeArrayCreateExpression(CodeTypeReference, CodeExpression[]) CodeArrayCreateExpression(CodeTypeReference, CodeExpression[]) CodeArrayCreateExpression(CodeTypeReference, CodeExpression[])

使用指定的陣列資料型別和初始化運算式,初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and initialization expressions.

CodeArrayCreateExpression(CodeTypeReference, Int32) CodeArrayCreateExpression(CodeTypeReference, Int32) CodeArrayCreateExpression(CodeTypeReference, Int32) CodeArrayCreateExpression(CodeTypeReference, Int32)

使用指定的陣列資料型別和陣列的索引數目,初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and number of indexes for the array.

CodeArrayCreateExpression(String, CodeExpression) CodeArrayCreateExpression(String, CodeExpression) CodeArrayCreateExpression(String, CodeExpression) CodeArrayCreateExpression(String, CodeExpression)

使用指定的陣列資料型別名稱和指示陣列的索引數目的程式碼運算式,初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and code expression indicating the number of indexes for the array.

CodeArrayCreateExpression(String, CodeExpression[]) CodeArrayCreateExpression(String, CodeExpression[]) CodeArrayCreateExpression(String, CodeExpression[]) CodeArrayCreateExpression(String, CodeExpression[])

使用指定的陣列資料型別名稱和初始設定式,初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and initializers.

CodeArrayCreateExpression(String, Int32) CodeArrayCreateExpression(String, Int32) CodeArrayCreateExpression(String, Int32) CodeArrayCreateExpression(String, Int32)

使用指定的陣列資料型別名稱和陣列的索引數目,初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type name and number of indexes for the array.

CodeArrayCreateExpression(Type, CodeExpression) CodeArrayCreateExpression(Type, CodeExpression) CodeArrayCreateExpression(Type, CodeExpression) CodeArrayCreateExpression(Type, CodeExpression)

使用指定的陣列資料型別和指示陣列的索引數目的程式碼運算式,初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and code expression indicating the number of indexes for the array.

CodeArrayCreateExpression(Type, CodeExpression[]) CodeArrayCreateExpression(Type, CodeExpression[]) CodeArrayCreateExpression(Type, CodeExpression[]) CodeArrayCreateExpression(Type, CodeExpression[])

使用指定的陣列資料型別和初始設定式來初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and initializers.

CodeArrayCreateExpression(Type, Int32) CodeArrayCreateExpression(Type, Int32) CodeArrayCreateExpression(Type, Int32) CodeArrayCreateExpression(Type, Int32)

使用指定的陣列資料型別和陣列的索引數目,初始化 CodeArrayCreateExpression 類別的新執行個體。Initializes a new instance of the CodeArrayCreateExpression class using the specified array data type and number of indexes for the array.

屬性

CreateType CreateType CreateType CreateType

取得或設定要建立陣列的型別。Gets or sets the type of array to create.

Initializers Initializers Initializers Initializers

取得用來初始化陣列的初始設定式。Gets the initializers with which to initialize the array.

Size Size Size Size

取得或設定陣列的索引數目。Gets or sets the number of indexes in the array.

SizeExpression SizeExpression SizeExpression SizeExpression

取得或設定指示陣列大小的運算式。Gets or sets the expression that indicates the size of the array.

UserData UserData UserData UserData

取得目前物件的使用者可定義資料。Gets the user-definable data for the current object.

(Inherited from CodeObject)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱