NewObjectExpression Class
Represents an object instantiation expression using the new keyword.
public class NewObjectExpression : ExpressionExample
var newObj = new NewObjectExpression(typeof(StringBuilder));
var newObjWithArgs = new NewObjectExpression(typeof(StringBuilder), new LiteralExpression("initial value"));
Assert.Equal("new global::System.Text.StringBuilder()", newObj.ToCsharpString());
Assert.Equal("new global::System.Text.StringBuilder(\"initial value\")", newObjWithArgs.ToCsharpString());- Inheritance
ExpressionNewObjectExpression
Constructors
| Name | Description |
|---|---|
| NewObjectExpression() | |
| NewObjectExpression(TypeReference?, Expression[]) | Initializes a new instance of the NewObjectExpression class with the specified type and constructor arguments. |
NewObjectExpression overloads
NewObjectExpression()
NewObjectExpression.cspublic NewObjectExpression()No documentation is available.
NewObjectExpression(TypeReference?, Expression[])
NewObjectExpression.csInitializes a new instance of the NewObjectExpression class with the specified type and constructor arguments.
public NewObjectExpression(TypeReference? type, params Expression[] arguments)Parameters
typeTypeReference?- The type to instantiate.
argumentsExpression[]- The constructor arguments.
Properties
| Name | Description |
|---|---|
| Arguments | |
| Type |
Arguments
NewObjectExpression.cspublic CodeObjectCollection<Expression> Arguments { get; }Property value
No documentation is available.