Redigera

CodeObjectCreateExpression Class

Definition

Represents an expression that creates a new instance of a type.

public ref class CodeObjectCreateExpression : System::CodeDom::CodeExpression
public class CodeObjectCreateExpression : System.CodeDom.CodeExpression
type CodeObjectCreateExpression = class
    inherit CodeExpression
Public Class CodeObjectCreateExpression
Inherits CodeExpression
Inheritance
CodeObjectCreateExpression

Examples

The following example demonstrates use of CodeObjectCreateExpression to create a new instance of the System.DateTime class using the parameterless constructor.

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

Remarks

CodeObjectCreateExpression can be used to represent an expression that creates an instance of a type.

The CreateType property specifies the data type to create a new instance of. The Parameters property specifies the parameters to pass to the constructor of the type to create a new instance of.

Constructors

Name Description
CodeObjectCreateExpression()

Initializes a new instance of the CodeObjectCreateExpression class.

CodeObjectCreateExpression(CodeTypeReference, CodeExpression[])

Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

CodeObjectCreateExpression(String, CodeExpression[])

Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

CodeObjectCreateExpression(Type, CodeExpression[])

Initializes a new instance of the CodeObjectCreateExpression class using the specified type and parameters.

Properties

Name Description
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.

(Inherited from CodeObject)

Applies to