Expression.Increment 方法

定义

创建一个 UnaryExpression,它表示按 1 递增表达式值。Creates a UnaryExpression that represents the incrementing of the expression value by 1.

重载

Increment(Expression, MethodInfo)

创建一个 UnaryExpression,它表示按 1 递增表达式值。Creates a UnaryExpression that represents the incrementing of the expression by 1.

Increment(Expression)

创建一个 UnaryExpression,它表示按 1 递增表达式值。Creates a UnaryExpression that represents the incrementing of the expression value by 1.

Increment(Expression, MethodInfo)

创建一个 UnaryExpression,它表示按 1 递增表达式值。Creates a UnaryExpression that represents the incrementing of the expression by 1.

public:
 static System::Linq::Expressions::UnaryExpression ^ Increment(System::Linq::Expressions::Expression ^ expression, System::Reflection::MethodInfo ^ method);
public static System.Linq.Expressions.UnaryExpression Increment (System.Linq.Expressions.Expression expression, System.Reflection.MethodInfo method);
public static System.Linq.Expressions.UnaryExpression Increment (System.Linq.Expressions.Expression expression, System.Reflection.MethodInfo? method);
static member Increment : System.Linq.Expressions.Expression * System.Reflection.MethodInfo -> System.Linq.Expressions.UnaryExpression
Public Shared Function Increment (expression As Expression, method As MethodInfo) As UnaryExpression

参数

expression
Expression

要递增的 ExpressionAn Expression to increment.

method
MethodInfo

表示实现方法的 MethodInfoA MethodInfo that represents the implementing method.

返回

UnaryExpression

一个表示已递增的表达式的 UnaryExpressionA UnaryExpression that represents the incremented expression.

注解

此表达式是有效的,并且不会更改传递给它的对象的值。This expression is functional and does not change the value of the object that is passed to it.

适用于

Increment(Expression)

创建一个 UnaryExpression,它表示按 1 递增表达式值。Creates a UnaryExpression that represents the incrementing of the expression value by 1.

public:
 static System::Linq::Expressions::UnaryExpression ^ Increment(System::Linq::Expressions::Expression ^ expression);
public static System.Linq.Expressions.UnaryExpression Increment (System.Linq.Expressions.Expression expression);
static member Increment : System.Linq.Expressions.Expression -> System.Linq.Expressions.UnaryExpression
Public Shared Function Increment (expression As Expression) As UnaryExpression

参数

expression
Expression

要递增的 ExpressionAn Expression to increment.

返回

UnaryExpression

一个表示已递增的表达式的 UnaryExpressionA UnaryExpression that represents the incremented expression.

示例

下面的代码示例演示如何创建表示增量运算的表达式。The following code example shows how to create an expression that represents an increment operation.

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

// This expression represents an increment operation.
double num = 5.5;
Expression incrementExpr = Expression.Increment(
                            Expression.Constant(num)
                        );

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

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

// The value of the variable did not change,
// because the expression is functional.
Console.WriteLine("object: " + num);

// This code example produces the following output:
//
// Increment(5.5)
// 6.5
// object: 5.5
'Add the following directive to your file:
' Imports System.Linq.Expressions   

Dim num As Double = 5.5
' This expression represents an increment operation. 
Dim incrementExpr As Expression = Expression.Increment(
                            Expression.Constant(num)
                        )

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

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

' The value of the variable did not change,
' because the expression is functional.
Console.WriteLine("object: " & num)

' This code example produces the following output:
'
' Increment(5.5)
' 6.5
' object: 5.5

注解

此表达式是有效的,并且不会更改传递给它的对象的值。This expression is functional and does not change the value of the object that is passed to it.

适用于