CodeObjectCreateExpression Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- 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
Feedback
https://aka.ms/ContentUserFeedback.
Binnenkort: Gedurende 2024 worden GitHub Issues uitgefaseerd als het feedbackmechanisme voor inhoud. Dit wordt vervangen door een nieuw feedbacksysteem. Ga voor meer informatie naar:Feedback verzenden en bekijken voor