Expression.Add Metodo

Definizione

Crea un oggetto BinaryExpression che rappresenta un'operazione di addizione aritmetica che non dispone del controllo dell'overflow.

Overload

Nome Descrizione
Add(Expression, Expression)

Crea un oggetto BinaryExpression che rappresenta un'operazione di addizione aritmetica che non dispone del controllo dell'overflow.

Add(Expression, Expression, MethodInfo)

Crea un oggetto BinaryExpression che rappresenta un'operazione di addizione aritmetica che non dispone del controllo dell'overflow. È possibile specificare il metodo di implementazione.

Add(Expression, Expression)

Crea un oggetto BinaryExpression che rappresenta un'operazione di addizione aritmetica che non dispone del controllo dell'overflow.

public:
 static System::Linq::Expressions::BinaryExpression ^ Add(System::Linq::Expressions::Expression ^ left, System::Linq::Expressions::Expression ^ right);
public static System.Linq.Expressions.BinaryExpression Add(System.Linq.Expressions.Expression left, System.Linq.Expressions.Expression right);
static member Add : System.Linq.Expressions.Expression * System.Linq.Expressions.Expression -> System.Linq.Expressions.BinaryExpression
Public Shared Function Add (left As Expression, right As Expression) As BinaryExpression

Parametri

left
Expression

Oggetto Expression su cui impostare la Left proprietà uguale.

right
Expression

Oggetto Expression su cui impostare la Right proprietà uguale.

Valori restituiti

Oggetto BinaryExpression con la NodeType proprietà uguale a Add e le Left proprietà e Right impostate sui valori specificati.

Eccezioni

left o right è null.

L'operatore di addizione non è definito per left. Digitare e right. Digitare.

Esempio

Nell'esempio di codice seguente viene illustrato come creare un'espressione che aggiunge due numeri interi.

// Add the following directive to your file:
// using System.Linq.Expressions;

// This expression adds the values of its two arguments.
// Both arguments must be of the same type.
Expression sumExpr = Expression.Add(
    Expression.Constant(1),
    Expression.Constant(2)
);

// Print out the expression.
Console.WriteLine(sumExpr.ToString());

// The following statement first creates an expression tree,
// then compiles it, and then executes it.
Console.WriteLine(Expression.Lambda<Func<int>>(sumExpr).Compile()());

// This code example produces the following output:
//
// (1 + 2)
// 3
' Add the following directive to your file:
' Imports System.Linq.Expressions  

' This expression adds the values of its two arguments.
' Both arguments must be of the same type.
Dim sumExpr As Expression = Expression.Add(
    Expression.Constant(1),
    Expression.Constant(2)
    )

' Print the expression.
Console.WriteLine(sumExpr.ToString())

' The following statement first creates an expression tree,
' then compiles it, and then executes it.            
Console.WriteLine(Expression.Lambda(Of Func(Of Integer))(sumExpr).Compile()())

' This code example produces the following output:
'
' (1 + 2)
' 3

Commenti

Per altre informazioni su questa API, vedere Osservazioni supplementari sulle API per Expression.Add.

Si applica a

Add(Expression, Expression, MethodInfo)

Crea un oggetto BinaryExpression che rappresenta un'operazione di addizione aritmetica che non dispone del controllo dell'overflow. È possibile specificare il metodo di implementazione.

public:
 static System::Linq::Expressions::BinaryExpression ^ Add(System::Linq::Expressions::Expression ^ left, System::Linq::Expressions::Expression ^ right, System::Reflection::MethodInfo ^ method);
public static System.Linq.Expressions.BinaryExpression Add(System.Linq.Expressions.Expression left, System.Linq.Expressions.Expression right, System.Reflection.MethodInfo method);
static member Add : System.Linq.Expressions.Expression * System.Linq.Expressions.Expression * System.Reflection.MethodInfo -> System.Linq.Expressions.BinaryExpression
Public Shared Function Add (left As Expression, right As Expression, method As MethodInfo) As BinaryExpression

Parametri

left
Expression

Oggetto Expression su cui impostare la Left proprietà uguale.

right
Expression

Oggetto Expression su cui impostare la Right proprietà uguale.

method
MethodInfo

Oggetto MethodInfo su cui impostare la Method proprietà uguale.

Valori restituiti

Oggetto BinaryExpression con la NodeType proprietà uguale a Add e le Leftproprietà e RightMethod impostate sui valori specificati.

Eccezioni

left o right è null.

method non null è e il metodo che rappresenta restituisce void, non static è (Shared in Visual Basic) o non accetta esattamente due argomenti.

method è null e l'operatore di addizione non è definito per left. Digitare e right. Digitare.

Commenti

Per altre informazioni su questa API, vedere Osservazioni supplementari sulle API per Expression.Add.

Si applica a