Expression.Add Metoda

Definicja

Tworzy element reprezentujący operację BinaryExpression dodawania arytmetycznego, która nie ma sprawdzania przepełnienia.

Przeciążenia

Add(Expression, Expression)

Tworzy element reprezentujący operację BinaryExpression dodawania arytmetycznego, która nie ma sprawdzania przepełnienia.

Add(Expression, Expression, MethodInfo)

Tworzy element reprezentujący operację BinaryExpression dodawania arytmetycznego, która nie ma sprawdzania przepełnienia. Można określić metodę implementowania.

Add(Expression, Expression)

Źródło:
BinaryExpression.cs
Źródło:
BinaryExpression.cs
Źródło:
BinaryExpression.cs

Tworzy element reprezentujący operację BinaryExpression dodawania arytmetycznego, która nie ma sprawdzania przepełnienia.

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

Parametry

left
Expression

A Expression , aby ustawić właściwość równą Left .

right
Expression

A Expression , aby ustawić właściwość równą Right .

Zwraca

WłaściwośćBinaryExpression, która ma właściwość równą AddNodeType właściwości i i RightLeft ustawioną na określone wartości.

Wyjątki

left lub right to null.

Operator dodawania nie jest zdefiniowany dla leftelementu . Wpisz i right. Typu.

Przykłady

W poniższym przykładzie kodu pokazano, jak utworzyć wyrażenie, które dodaje dwie liczby całkowite.

// 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

Uwagi

Aby uzyskać więcej informacji na temat tego interfejsu API, zobacz Dodatkowe uwagi dotyczące interfejsu API dla elementu Expression.Add.

Dotyczy

Add(Expression, Expression, MethodInfo)

Źródło:
BinaryExpression.cs
Źródło:
BinaryExpression.cs
Źródło:
BinaryExpression.cs

Tworzy element reprezentujący operację BinaryExpression dodawania arytmetycznego, która nie ma sprawdzania przepełnienia. Można określić metodę implementowania.

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

Parametry

left
Expression

A Expression , aby ustawić właściwość równą Left .

right
Expression

A Expression , aby ustawić właściwość równą Right .

method
MethodInfo

A MethodInfo , aby ustawić właściwość równą Method .

Zwraca

WłaściwośćBinaryExpression, która ma właściwość równą AddNodeType i LeftRight , i właściwości Method ustawione na określone wartości.

Wyjątki

left lub right to null.

method nie null jest i metoda, która reprezentuje zwraca voidwartość , nie static jest (Shared w Visual Basic) lub nie bierze dokładnie dwóch argumentów.

method jest null i operator dodawania nie jest zdefiniowany dla leftelementu . Wpisz i right. Typu.

Uwagi

Aby uzyskać więcej informacji na temat tego interfejsu API, zobacz Dodatkowe uwagi dotyczące interfejsu API dla elementu Expression.Add.

Dotyczy