CodeObjectCreateExpression CodeObjectCreateExpression CodeObjectCreateExpression CodeObjectCreateExpression Class

定義

表示建立型別之新執行個體的運算式。Represents an expression that creates a new instance of a type.

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

範例

下列範例示範CodeObjectCreateExpression如何使用, 以使用無參數的函式來建立 system.string 類別的新實例。The following example demonstrates use of CodeObjectCreateExpression to create a new instance of the System.DateTime class using the parameterless constructor.

array<CodeExpression^>^temp0 = gcnew array<CodeExpression^>(0);
CodeObjectCreateExpression^ objectCreate1 = gcnew CodeObjectCreateExpression( "System.DateTime",temp0 );

// A C# code generator produces the following source code for the preceeding example code:
//        new System.DateTime();
CodeObjectCreateExpression objectCreate1 = new CodeObjectCreateExpression( "System.DateTime", new CodeExpression[] {} );            

// A C# code generator produces the following source code for the preceeding example code:    

//        new System.DateTime();
Dim objectCreate1 As New CodeObjectCreateExpression("System.DateTime", New CodeExpression() {})

' A Visual Basic code generator produces the following source code for the preceeding example code:	

'       New Date

備註

CodeObjectCreateExpression可以用來代表建立型別實例的運算式。CodeObjectCreateExpression can be used to represent an expression that creates an instance of a type.

CreateType屬性會指定要建立新實例的資料類型。The CreateType property specifies the data type to create a new instance of. Parameters屬性會指定要傳遞至型別之函式的參數, 以建立的新實例。The Parameters property specifies the parameters to pass to the constructor of the type to create a new instance of.

建構函式

CodeObjectCreateExpression() CodeObjectCreateExpression() CodeObjectCreateExpression() CodeObjectCreateExpression()

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

CodeObjectCreateExpression(CodeTypeReference, CodeExpression[]) CodeObjectCreateExpression(CodeTypeReference, CodeExpression[]) CodeObjectCreateExpression(CodeTypeReference, CodeExpression[]) CodeObjectCreateExpression(CodeTypeReference, CodeExpression[])

使用指定的型別和參數來初始化 CodeObjectCreateExpression 類別的新執行個體。Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

CodeObjectCreateExpression(String, CodeExpression[]) CodeObjectCreateExpression(String, CodeExpression[]) CodeObjectCreateExpression(String, CodeExpression[]) CodeObjectCreateExpression(String, CodeExpression[])

使用指定的型別和參數來初始化 CodeObjectCreateExpression 類別的新執行個體。Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

CodeObjectCreateExpression(Type, CodeExpression[]) CodeObjectCreateExpression(Type, CodeExpression[]) CodeObjectCreateExpression(Type, CodeExpression[]) CodeObjectCreateExpression(Type, CodeExpression[])

使用指定的型別和參數來初始化 CodeObjectCreateExpression 類別的新執行個體。Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

屬性

CreateType CreateType CreateType CreateType

取得或設定要建立物件的資料型別。Gets or sets the data type of the object to create.

Parameters Parameters Parameters Parameters

取回或設定在建立物件時使用的參數。Gets or sets the parameters to use in creating the object.

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)

適用於