Expression.Decrement Méthode

Définition

Crée un UnaryExpression qui représente la décrémentation de l'expression par 1.

Surcharges

Decrement(Expression)

Crée un UnaryExpression qui représente la décrémentation de l'expression par 1.

Decrement(Expression, MethodInfo)

Crée un UnaryExpression qui représente la décrémentation de l'expression par 1.

Decrement(Expression)

Crée un UnaryExpression qui représente la décrémentation de l'expression par 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

Paramètres

expression
Expression

Expression à décrémenter.

Retours

UnaryExpression

UnaryExpression qui représente l'expression décrémentée.

Exemples

L’exemple de code suivant montre comment créer une expression qui soustrait 1 d’une valeur donnée.

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

Remarques

Cette expression est fonctionnelle et ne modifie pas la valeur de l’objet qui lui est passé.

S’applique à

Decrement(Expression, MethodInfo)

Crée un UnaryExpression qui représente la décrémentation de l'expression par 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

Paramètres

expression
Expression

Expression à décrémenter.

method
MethodInfo

MethodInfo qui représente la méthode d'implémentation.

Retours

UnaryExpression

UnaryExpression qui représente l'expression décrémentée.

Remarques

Cette expression est fonctionnelle et ne modifie pas la valeur de l’objet qui lui est passé.

S’applique à