Expression.Decrement Expression.Decrement Expression.Decrement Method

定義

式の値を 1 つ減らすデクリメントを表す UnaryExpression を作成します。Creates a UnaryExpression that represents the decrementing of the expression by 1.

オーバーロード

Decrement(Expression) Decrement(Expression) Decrement(Expression)

式の値を 1 つ減らすデクリメントを表す UnaryExpression を作成します。Creates a UnaryExpression that represents the decrementing of the expression by 1.

Decrement(Expression, MethodInfo) Decrement(Expression, MethodInfo) Decrement(Expression, MethodInfo)

式の値を 1 つ減らすデクリメントを表す UnaryExpression を作成します。Creates a UnaryExpression that represents the decrementing of the expression by 1.

Decrement(Expression) Decrement(Expression) Decrement(Expression)

式の値を 1 つ減らすデクリメントを表す UnaryExpression を作成します。Creates a UnaryExpression that represents the decrementing of the expression by 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

パラメーター

expression
Expression Expression Expression

デクリメントする ExpressionAn Expression to decrement.

戻り値

デクリメントされた式を表す UnaryExpressionA UnaryExpression that represents the decremented expression.

次のコード例では、指定された値から 1 を減算する式を作成する方法を示します。The following code example shows how to create an expression that subtracts 1 from a given value.

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

注釈

この式は、機能に渡されるオブジェクトの値を変更することはできません。This expression is functional and does not change the value of the object passed to it.

Decrement(Expression, MethodInfo) Decrement(Expression, MethodInfo) Decrement(Expression, MethodInfo)

式の値を 1 つ減らすデクリメントを表す UnaryExpression を作成します。Creates a UnaryExpression that represents the decrementing of the expression by 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);
static member Decrement : System.Linq.Expressions.Expression * System.Reflection.MethodInfo -> System.Linq.Expressions.UnaryExpression

パラメーター

expression
Expression Expression Expression

デクリメントする ExpressionAn Expression to decrement.

method
MethodInfo MethodInfo MethodInfo

メソッドの実装を表す MethodInfoA MethodInfo that represents the implementing method.

戻り値

デクリメントされた式を表す UnaryExpressionA UnaryExpression that represents the decremented expression.

注釈

この式は、機能に渡されるオブジェクトの値を変更することはできません。This expression is functional and does not change the value of the object passed to it.

適用対象