Expression.Add Metodo

Definizione

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

Overload

Add(Expression, Expression)

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

Add(Expression, Expression, MethodInfo)

Crea un oggetto BinaryExpression che rappresenta un'operazione di addizione aritmetica che non ha il controllo dell'overflow. Il metodo di implementazione può essere specificato.

Add(Expression, Expression)

Origine:
BinaryExpression.cs
Origine:
BinaryExpression.cs
Origine:
BinaryExpression.cs

Crea un oggetto BinaryExpression che rappresenta un'operazione di addizione aritmetica che non ha il 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 proprietà Left.

right
Expression

Oggetto Expression su cui impostare la proprietà Right.

Restituisce

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

Eccezioni

left o right è null.

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

Esempio

Nell'esempio di codice seguente viene illustrato come creare un'espressione che aggiunge due 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 api supplementari per Expression.Add.

Si applica a

Add(Expression, Expression, MethodInfo)

Origine:
BinaryExpression.cs
Origine:
BinaryExpression.cs
Origine:
BinaryExpression.cs

Crea un oggetto BinaryExpression che rappresenta un'operazione di addizione aritmetica che non ha il controllo dell'overflow. Il metodo di implementazione può essere specificato.

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);
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 proprietà Left.

right
Expression

Oggetto Expression su cui impostare la proprietà Right.

method
MethodInfo

Oggetto MethodInfo su cui impostare la proprietà Method.

Restituisce

Oggetto BinaryExpression la cui proprietà NodeType è uguale a Add e le cui proprietà Left, Right e Method sono 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) oppure non accetta esattamente due argomenti.

method è null e l'operatore di addizione non è definito per i tipi left.Type e right.Type.

Commenti

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

Si applica a