Expression.Continue Methode

Definitie

Hiermee maakt u een GotoExpression weergave van een continue instructie.

Overloads

Name Description
Continue(LabelTarget)

Hiermee maakt u een GotoExpression weergave van een continue instructie.

Continue(LabelTarget, Type)

Hiermee maakt u een GotoExpression weergave van een continue instructie met het opgegeven type.

Continue(LabelTarget)

Bron:
GotoExpression.cs
Bron:
GotoExpression.cs
Bron:
GotoExpression.cs
Bron:
GotoExpression.cs
Bron:
GotoExpression.cs

Hiermee maakt u een GotoExpression weergave van een continue instructie.

public:
 static System::Linq::Expressions::GotoExpression ^ Continue(System::Linq::Expressions::LabelTarget ^ target);
public static System.Linq.Expressions.GotoExpression Continue(System.Linq.Expressions.LabelTarget target);
static member Continue : System.Linq.Expressions.LabelTarget -> System.Linq.Expressions.GotoExpression
Public Shared Function Continue (target As LabelTarget) As GotoExpression

Parameters

target
LabelTarget

De LabelTarget die de GotoExpression zal springen.

Retouren

Een GotoExpression met Kind gelijk aan Doorgaan, de Target eigenschap ingesteld op targeten een null-waarde die moet worden doorgegeven aan het doellabel bij het springen.

Voorbeelden

In het volgende voorbeeld ziet u hoe u een lusexpressie maakt die gebruikmaakt van de Continue methode.

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

// A label that is used by a break statement and a loop.
LabelTarget breakLabel = Expression.Label();

// A label that is used by the Continue statement and the loop it refers to.
LabelTarget continueLabel = Expression.Label();

// This expression represents a Continue statement.
Expression continueExpr = Expression.Continue(continueLabel);

// A variable that triggers the exit from the loop.
ParameterExpression count = Expression.Parameter(typeof(int));

// A loop statement.
Expression loopExpr = Expression.Loop(
    Expression.Block(
        Expression.IfThen(
            Expression.GreaterThan(count, Expression.Constant(3)),
            Expression.Break(breakLabel)
        ),
        Expression.PreIncrementAssign(count),
        Expression.Call(
                    null,
                    typeof(Console).GetMethod("WriteLine", new Type[] { typeof(String) }),
                    Expression.Constant("Loop")
                ),
        continueExpr,
        Expression.PreDecrementAssign(count)
    ),
    breakLabel,
    continueLabel
);

// The following statement first creates an expression tree,
// then compiles it, and then runs it.
// Without the Continue statement, the loop would go on forever.
Expression.Lambda<Action<int>>(loopExpr, count).Compile()(1);

// This code example produces the following output:
//
// Loop
// Loop
// Loop
' Add the following directive to your file:
' Imports System.Linq.Expressions  

' A label that is used by a break statement and a loop. 
Dim breakLabel As LabelTarget = Expression.Label()

' A label that is used by the Continue statement and the loop it refers to.
Dim continueLabel As LabelTarget = Expression.Label()

' This expression represents a Continue statement.
Dim continueExpr As Expression = Expression.Continue(continueLabel)

' A variable that triggers the exit from the loop.
Dim count As ParameterExpression = Expression.Parameter(GetType(Integer))

' A loop statement.
Dim loopExpr As Expression = Expression.Loop(
       Expression.Block(
           Expression.IfThen(
               Expression.GreaterThan(count, Expression.Constant(3)),
               Expression.Break(breakLabel)
           ),
           Expression.PreIncrementAssign(count),
           Expression.Call(
                       Nothing,
                       GetType(Console).GetMethod("WriteLine", New Type() {GetType(String)}),
                       Expression.Constant("Loop")
                   ),
           continueExpr,
           Expression.PreDecrementAssign(count)
       ),
       breakLabel,
       continueLabel
   )

' The following statement first creates an expression tree,
' then compiles it, and then runs it.
' Without the Continue statement, the loop would go on forever.
Expression.Lambda(Of Action(Of Integer))(loopExpr, count).Compile()(1)

' This code example produces the following output:
'
' Loop
' Loop
' Loop

Van toepassing op

Continue(LabelTarget, Type)

Bron:
GotoExpression.cs
Bron:
GotoExpression.cs
Bron:
GotoExpression.cs
Bron:
GotoExpression.cs
Bron:
GotoExpression.cs

Hiermee maakt u een GotoExpression weergave van een continue instructie met het opgegeven type.

public:
 static System::Linq::Expressions::GotoExpression ^ Continue(System::Linq::Expressions::LabelTarget ^ target, Type ^ type);
public static System.Linq.Expressions.GotoExpression Continue(System.Linq.Expressions.LabelTarget target, Type type);
static member Continue : System.Linq.Expressions.LabelTarget * Type -> System.Linq.Expressions.GotoExpression
Public Shared Function Continue (target As LabelTarget, type As Type) As GotoExpression

Parameters

target
LabelTarget

De LabelTarget die de GotoExpression zal springen.

type
Type

Een Type om de Type eigenschap in te stellen die gelijk is aan.

Retouren

Een GotoExpression met Kind gelijk aan Doorgaan, de Target eigenschap ingesteld op target, de Type eigenschap ingesteld op typeen een null-waarde die moet worden doorgegeven aan het doellabel bij het springen.

Van toepassing op