NewExpression Class (System.Linq.Expressions) (original) (raw)

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 a constructor call.

public ref class NewExpression : System::Linq::Expressions::Expression, System::Linq::Expressions::IArgumentProvider
public ref class NewExpression sealed : System::Linq::Expressions::Expression
public ref class NewExpression : System::Linq::Expressions::Expression
public class NewExpression : System.Linq.Expressions.Expression, System.Linq.Expressions.IArgumentProvider
public sealed class NewExpression : System.Linq.Expressions.Expression
public class NewExpression : System.Linq.Expressions.Expression
type NewExpression = class
    inherit Expression
    interface IArgumentProvider
type NewExpression = class
    inherit Expression
Public Class NewExpression
Inherits Expression
Implements IArgumentProvider
Public NotInheritable Class NewExpression
Inherits Expression
Public Class NewExpression
Inherits Expression

Inheritance

Implements

Examples

The following example creates a NewExpression that represents the construction of a new instance of a dictionary object.

// Create a NewExpression that represents constructing
// a new instance of Dictionary<int, string>.
System.Linq.Expressions.NewExpression newDictionaryExpression =
    System.Linq.Expressions.Expression.New(typeof(Dictionary<int, string>));

Console.WriteLine(newDictionaryExpression.ToString());

// This code produces the following output:
//
// new Dictionary`2()
' Create a NewExpression that represents constructing
' a new instance of Dictionary(Of Integer, String).
Dim newDictionaryExpression As System.Linq.Expressions.NewExpression = _
    System.Linq.Expressions.Expression.[New]( _
        Type.GetType("System.Collections.Generic.Dictionary`2[System.Int32, System.String]"))

Console.WriteLine(newDictionaryExpression.ToString())

' This code produces the following output:
'
' new Dictionary`2()

Remarks

Use the New factory methods to create a NewExpression.

The value of the NodeType property of a NewExpression object is New.

Applies to