Expression.Goto 메서드

정의

"go to" 문을 나타내는 GotoExpression을 만듭니다.

오버로드

Goto(LabelTarget, Expression, Type)

지정된 형식을 사용하여 "go to" 문을 나타내는 GotoExpression을 만듭니다. 이동 시 레이블에 전달되는 값을 지정할 수 있습니다.

Goto(LabelTarget, Type)

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

Goto(LabelTarget)

"go to" 문을 나타내는 GotoExpression을 만듭니다.

Goto(LabelTarget, Expression)

"go to" 문을 나타내는 GotoExpression을 만듭니다. 이동 시 레이블에 전달되는 값을 지정할 수 있습니다.

Goto(LabelTarget, Expression, Type)

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

지정된 형식을 사용하여 "go to" 문을 나타내는 GotoExpression을 만듭니다. 이동 시 레이블에 전달되는 값을 지정할 수 있습니다.

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

매개 변수

target
LabelTarget

LabelTarget이 이동할 GotoExpression입니다.

value
Expression

이동 시 연결된 레이블에 전달될 값입니다.

type
Type

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

반환

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

적용 대상

Goto(LabelTarget, Type)

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

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

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

매개 변수

target
LabelTarget

LabelTarget이 이동할 GotoExpression입니다.

type
Type

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

반환

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

적용 대상

Goto(LabelTarget)

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

"go to" 문을 나타내는 GotoExpression을 만듭니다.

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

매개 변수

target
LabelTarget

LabelTarget이 이동할 GotoExpression입니다.

반환

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

예제

다음 예제에서는 개체를 포함하는 식을 만드는 방법을 보여 줍니다 GotoExpression .

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

// A label expression of the void type that is the target for the GotoExpression.
LabelTarget returnTarget = Expression.Label();

// This block contains a GotoExpression.
// It transfers execution to a label expression that is initialized with the same LabelTarget as the GotoExpression.
// The types of the GotoExpression, label expression, and LabelTarget must match.
BlockExpression blockExpr =
    Expression.Block(
        Expression.Call(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }), Expression.Constant("GoTo")),
        Expression.Goto(returnTarget),
        Expression.Call(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }), Expression.Constant("Other Work")),
        Expression.Label(returnTarget)
    );

// The following statement first creates an expression tree,
// then compiles it, and then runs it.
Expression.Lambda<Action>(blockExpr).Compile()();

// This code example produces the following output:
//
// GoTo

// "Other Work" is not printed because
// the GoTo expression transfers execution from Expression.GoTo(returnTarget)
// to Expression.Label(returnTarget).
' Add the following directive to your file:
' Imports System.Linq.Expressions  

' A label expression of the void type that is the target for the GoToExpression.
Dim returnTarget As LabelTarget = Expression.Label()

' This block contains a GotoExpression.
' It transfers execution to a label expression that is initialized with the same LabelTarget as the GotoExpression.
' The types of the GotoExpression, label expression, and LabelTarget must match.
Dim blockExpr As BlockExpression =
      Expression.Block(
          Expression.Call(GetType(Console).GetMethod("WriteLine", New Type() {GetType(String)}), Expression.Constant("GoTo")),
          Expression.Goto(returnTarget),
          Expression.Call(GetType(Console).GetMethod("WriteLine", New Type() {GetType(String)}), Expression.Constant("Other Work")),
          Expression.Label(returnTarget)
      )

' The following statement first creates an expression tree,
' then compiles it, and then runs it.
Expression.Lambda(Of Action)(blockExpr).Compile()()

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

' "Other Work" is not printed because 
' the Return expression transfers execution from Expression.GoTo(returnTarget)
' to Expression.Label(returnTarget).

적용 대상

Goto(LabelTarget, Expression)

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

"go to" 문을 나타내는 GotoExpression을 만듭니다. 이동 시 레이블에 전달되는 값을 지정할 수 있습니다.

public:
 static System::Linq::Expressions::GotoExpression ^ Goto(System::Linq::Expressions::LabelTarget ^ target, System::Linq::Expressions::Expression ^ value);
public static System.Linq.Expressions.GotoExpression Goto (System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression value);
public static System.Linq.Expressions.GotoExpression Goto (System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression? value);
static member Goto : System.Linq.Expressions.LabelTarget * System.Linq.Expressions.Expression -> System.Linq.Expressions.GotoExpression
Public Shared Function Goto (target As LabelTarget, value As Expression) As GotoExpression

매개 변수

target
LabelTarget

LabelTarget이 이동할 GotoExpression입니다.

value
Expression

이동 시 연결된 레이블에 전달될 값입니다.

반환

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

적용 대상