Expression.Increment 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立 UnaryExpression,表示運算式值遞增 1。
多載
Increment(Expression, MethodInfo) |
建立 UnaryExpression,代表運算式遞增 1。 |
Increment(Expression) |
建立 UnaryExpression,表示運算式值遞增 1。 |
Increment(Expression, MethodInfo)
建立 UnaryExpression,代表運算式遞增 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
要遞增的 Expression。
- method
- MethodInfo
表示實作方法的 MethodInfo。
傳回
表示遞增後運算式的 UnaryExpression。
備註
此表達式功能正常,而且不會變更傳遞給它的物件值。
適用於
Increment(Expression)
建立 UnaryExpression,表示運算式值遞增 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
要遞增的 Expression。
傳回
表示遞增後運算式的 UnaryExpression。
範例
下列程式代碼範例示範如何建立代表遞增作業的表達式。
// 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
備註
此表達式功能正常,而且不會變更傳遞給它的物件值。