Expression.Goto Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Erstellt eine Darstellung einer GotoExpression "Go to"-Anweisung.
Überlädt
| Name | Beschreibung |
|---|---|
| Goto(LabelTarget, Expression, Type) |
Erstellt eine darstellung einer GotoExpression "go to"-Anweisung mit dem angegebenen Typ. Der wert, der beim Springen an die Beschriftung übergeben wird, kann angegeben werden. |
| Goto(LabelTarget, Type) |
Erstellt eine darstellung einer GotoExpression "go to"-Anweisung mit dem angegebenen Typ. |
| Goto(LabelTarget) |
Erstellt eine Darstellung einer GotoExpression "Go to"-Anweisung. |
| Goto(LabelTarget, Expression) |
Erstellt eine Darstellung einer GotoExpression "Go to"-Anweisung. Der wert, der beim Springen an die Beschriftung übergeben wird, kann angegeben werden. |
Goto(LabelTarget, Expression, Type)
Erstellt eine darstellung einer GotoExpression "go to"-Anweisung mit dem angegebenen Typ. Der wert, der beim Springen an die Beschriftung übergeben wird, kann angegeben werden.
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
Parameter
- target
- LabelTarget
Dies LabelTargetGotoExpression springt zu.
- value
- Expression
Der Wert, der beim Springen an die zugeordnete Beschriftung übergeben wird.
Gibt zurück
A GotoExpression with Kind equal to Goto, the Target property set to target, the Type property set to type, and value to be passed to the target label upon jumping.
Gilt für:
Goto(LabelTarget, Type)
Erstellt eine darstellung einer GotoExpression "go to"-Anweisung mit dem angegebenen Typ.
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
Parameter
- target
- LabelTarget
Dies LabelTargetGotoExpression springt zu.
Gibt zurück
A GotoExpression with Kind equal to Goto, the Target property set to the specified value, the Type property set to type, and a null value to be passed to the target label upon jumping.
Gilt für:
Goto(LabelTarget)
Erstellt eine Darstellung einer GotoExpression "Go to"-Anweisung.
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
Parameter
- target
- LabelTarget
Dies LabelTargetGotoExpression springt zu.
Gibt zurück
A GotoExpression with Kind equal to Goto, the Target property set to the specified value, and a null value to be passed to the target label upon jumping.
Beispiele
Das folgende Beispiel veranschaulicht das Erstellen eines Ausdrucks, der ein GotoExpression Objekt enthält.
// 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).
Gilt für:
Goto(LabelTarget, Expression)
Erstellt eine Darstellung einer GotoExpression "Go to"-Anweisung. Der wert, der beim Springen an die Beschriftung übergeben wird, kann angegeben werden.
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
Parameter
- target
- LabelTarget
Dies LabelTargetGotoExpression springt zu.
- value
- Expression
Der Wert, der beim Springen an die zugeordnete Beschriftung übergeben wird.
Gibt zurück
A GotoExpression with Kind equal to Goto, the Target property set to target, and value to be passed to the target label upon jumping.