CodeObjectCreateExpression 类

定义

表示创建某种类型的新实例的表达式。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
继承
CodeObjectCreateExpression
属性

示例

下面的示例演示CodeObjectCreateExpression如何使用来创建使用无参数构造函数的 system.object 类的新实例。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 类的新实例。Initializes a new instance of the CodeObjectCreateExpression class.

CodeObjectCreateExpression(CodeTypeReference, CodeExpression[])

使用指定的类型和参数初始化 CodeObjectCreateExpression 类的新实例。Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

CodeObjectCreateExpression(String, CodeExpression[])

使用指定的类型和参数初始化 CodeObjectCreateExpression 类的新实例。Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

CodeObjectCreateExpression(Type, CodeExpression[])

使用指定的类型和参数初始化 CodeObjectCreateExpression 类的新实例。Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

属性

CreateType

获取或设置要创建的对象的数据类型。Gets or sets the data type of the object to create.

Parameters

获取或设置创建对象时使用的参数。Gets or sets the parameters to use in creating the object.

UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于