संपादित करें

इसके माध्यम से साझा किया गया


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
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeObjectCreateExpression : System.CodeDom.CodeExpression
type CodeObjectCreateExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeObjectCreateExpression = class
    inherit CodeExpression
Public Class CodeObjectCreateExpression
Inherits CodeExpression
Inheritance
CodeObjectCreateExpression
Attributes

Examples

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

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

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

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)

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to