Expression.Goto メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
"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)
指定した型の "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
ジャンプ時に関連付けられているラベルに渡される値。
返品
Goto と等しいGotoExpressionを持つKind、Target プロパティを target に設定し、Type プロパティを type に設定し、ジャンプ時にターゲット ラベルに渡すvalue。
適用対象
Goto(LabelTarget, Type)
指定した型の "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。
返品
Goto と等しいGotoExpression、指定した値に設定されたKind プロパティ、Target プロパティをTypeに設定したtype、ジャンプ時にターゲット ラベルに渡される null 値。
適用対象
Goto(LabelTarget)
"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、指定した値に設定された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)
"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、Kind プロパティが Target に設定され、targetに等しいvalue。