CodeObjectCreateExpression CodeObjectCreateExpression CodeObjectCreateExpression CodeObjectCreateExpression Class

Definition

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

public ref class CodeObjectCreateExpression : System::CodeDom::CodeExpression
[System.Runtime.InteropServices.ClassInterface]
[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
Inheritance
CodeObjectCreateExpressionCodeObjectCreateExpressionCodeObjectCreateExpressionCodeObjectCreateExpression
Attributes

Examples

The following example demonstrates use of CodeObjectCreateExpression to create a new instance of the System.DateTime class using the default 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

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

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

Initializes a new instance of the CodeObjectCreateExpression class.

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

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[])

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[])

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

Properties

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)

Methods

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()

Gets the Type of the current instance.

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

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)

Applies to