語言

Expression.Goto 方法

定義

建立 GotoExpression 一個表示「必看」語句的訊息。

多載

名稱 Description
Goto(LabelTarget, Expression, Type)

建立 GotoExpression 一個代表指定型別的「go to」陳述句。 跳躍時傳遞給標籤的值可以指定。

Goto(LabelTarget, Type)

建立 GotoExpression 一個代表指定型別的「go to」陳述句。

Goto(LabelTarget)

建立 GotoExpression 一個表示「必看」語句的訊息。

Goto(LabelTarget, Expression)

建立 GotoExpression 一個表示「必看」語句的訊息。 跳躍時傳遞給標籤的值可以指定。

Goto(LabelTarget, Expression, Type)

來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs

建立 GotoExpression 一個代表指定型別的「go to」陳述句。 跳躍時傳遞給標籤的值可以指定。

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 A 將屬性Type設為 。

傳回

GotoExpression A 等Kind於 Goto,Target屬性設target為 ,Type屬性設為 type,value且跳躍時傳遞給目標標籤。

適用於

Goto(LabelTarget, Type)

來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs

建立 GotoExpression 一個代表指定型別的「go to」陳述句。

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 A 將屬性Type設為 。

傳回

一個 GotoExpression 等 Kind 於 Goto、 Target 屬性設定為指定值、 Type 屬性設定為 type、以及一個空值,跳躍時傳遞給目標標籤。

適用於

Goto(LabelTarget)

來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs

建立 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 等 Kind 於 Goto、 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)

來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs
來源:
GotoExpression.cs

建立 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 A 等Kind於 Goto,Target屬性設為 target,跳value躍時傳給目標標籤。

適用於