Expression.Continue 메서드

정의

continue 문을 나타내는 GotoExpression을 만듭니다.

오버로드

Continue(LabelTarget)

continue 문을 나타내는 GotoExpression을 만듭니다.

Continue(LabelTarget, Type)

지정된 형식을 사용하여 continue 문을 나타내는 GotoExpression을 만듭니다.

Continue(LabelTarget)

Source:
GotoExpression.cs
Source:
GotoExpression.cs
Source:
GotoExpression.cs

continue 문을 나타내는 GotoExpression을 만듭니다.

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

매개 변수

target
LabelTarget

LabelTarget이 이동할 GotoExpression입니다.

반환

GotoExpression가 Continue이고, Kind 속성이 Target으로 설정되며, 이동 시 대상 레이블에 null 값이 전달되는 target입니다.

예제

다음 예제에서는 메서드를 사용하는 Continue 루프 식을 만드는 방법을 보여 줍니다.

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

적용 대상

Continue(LabelTarget, Type)

Source:
GotoExpression.cs
Source:
GotoExpression.cs
Source:
GotoExpression.cs

지정된 형식을 사용하여 continue 문을 나타내는 GotoExpression을 만듭니다.

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

매개 변수

target
LabelTarget

LabelTarget이 이동할 GotoExpression입니다.

type
Type

Type 속성에 설정할 Type입니다.

반환

GotoExpression가 Continue이고, Kind 속성이 Target으로 설정되며, target 속성이 Type으로 설정되고, 이동 시 대상 레이블에 null 값이 전달되는 type입니다.

적용 대상