共用方式為


Expression.Decrement 方法

定義

建立 UnaryExpression,代表運算式遞減 1。

多載

Decrement(Expression)

建立 UnaryExpression,代表運算式遞減 1。

Decrement(Expression, MethodInfo)

建立 UnaryExpression,代表運算式遞減 1。

Decrement(Expression)

來源:
UnaryExpression.cs
來源:
UnaryExpression.cs
來源:
UnaryExpression.cs

建立 UnaryExpression,代表運算式遞減 1。

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

參數

expression
Expression

要遞減的 Expression

傳回

代表遞減後運算式的 UnaryExpression

範例

下列程式代碼範例示範如何建立從指定值減去 1 的表達式。

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

double num = 5.5;

// This expression represents a decrement operation
// that subtracts 1 from a value.
Expression decrementExpr = Expression.Decrement(
                            Expression.Constant(num)
                        );

// Print expression.
Console.WriteLine(decrementExpr.ToString());

// The following statement first creates an expression tree,
// then compiles it, and then executes it.
Console.WriteLine(
    Expression.Lambda<Func<double>>(decrementExpr).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:
//
// Decrement(5.5)
// 4.5
// object: 5.5
' Add the following directive to your file:
' Imports System.Linq.Expressions   

Dim num As Double = 5.5

' This expression represents a decrement operation 
' that subtracts 1 from a value. 
Dim decrementExpr As Expression = Expression.Decrement(
                            Expression.Constant(num)
                        )

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

' The following statement first creates an expression tree,
' then compiles it, and then executes it.
Console.WriteLine(
    Expression.Lambda(Of Func(Of Double))(decrementExpr).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:
'
' Decrement(5.5)
' 4.5
' object: 5.5

備註

此表達式可正常運作,而且不會變更傳遞給它的物件值。

適用於

Decrement(Expression, MethodInfo)

來源:
UnaryExpression.cs
來源:
UnaryExpression.cs
來源:
UnaryExpression.cs

建立 UnaryExpression,代表運算式遞減 1。

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

參數

expression
Expression

要遞減的 Expression

method
MethodInfo

表示實作方法的 MethodInfo

傳回

代表遞減後運算式的 UnaryExpression

備註

此表達式可正常運作,而且不會變更傳遞給它的物件值。

適用於