CodeObjectCreateExpression Class
TOC
Collapse the table of content
Expand the table of content

CodeObjectCreateExpression Class

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

For a list of all members of this type, see CodeObjectCreateExpression Members.

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeExpression
         System.CodeDom.CodeObjectCreateExpression

[Visual Basic]
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeObjectCreateExpression
   Inherits CodeExpression
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeObjectCreateExpression : CodeExpression
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeObjectCreateExpression : public
   CodeExpression
[JScript]
public
   Serializable
 ClassInterface(ClassInterfaceType.AutoDispatch)
 ComVisible(true)
class CodeObjectCreateExpression extends CodeExpression

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

Example

[Visual Basic, C#, C++] The following example demonstrates use of CodeObjectCreateExpression to create a new instance of the System.DateTime class using the default constructor.

[Visual Basic] 
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

[C#] 
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();

[C++] 

        CodeExpression* temp0 [];
        CodeObjectCreateExpression* objectCreate1 = new CodeObjectCreateExpression( S"System.DateTime", temp0 );

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

        //        new System.DateTime();

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.CodeDom

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

CodeObjectCreateExpression Members | System.CodeDom Namespace

Show:
© 2016 Microsoft