Expression.Goto Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a".
Overload
| Nome | Descrizione |
|---|---|
| Goto(LabelTarget, Expression, Type) |
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a" con il tipo specificato. È possibile specificare il valore passato all'etichetta al passaggio. |
| Goto(LabelTarget, Type) |
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a" con il tipo specificato. |
| Goto(LabelTarget) |
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a". |
| Goto(LabelTarget, Expression) |
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a". È possibile specificare il valore passato all'etichetta al passaggio. |
Goto(LabelTarget, Expression, Type)
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a" con il tipo specificato. È possibile specificare il valore passato all'etichetta al passaggio.
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
Parametri
- target
- LabelTarget
Oggetto LabelTarget a cui passerà.GotoExpression
- value
- Expression
Valore che verrà passato all'etichetta associata al passaggio.
Valori restituiti
Oggetto GotoExpression con Kind uguale a Goto, la Target proprietà impostata su target, la Type proprietà impostata su typee value da passare all'etichetta di destinazione al momento del salto.
Si applica a
Goto(LabelTarget, Type)
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a" con il tipo specificato.
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
Parametri
- target
- LabelTarget
Oggetto LabelTarget a cui passerà.GotoExpression
Valori restituiti
Oggetto GotoExpression con Kind uguale a Goto, la Target proprietà impostata sul valore specificato, la Type proprietà impostata su typee un valore Null da passare all'etichetta di destinazione al passaggio.
Si applica a
Goto(LabelTarget)
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a".
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
Parametri
- target
- LabelTarget
Oggetto LabelTarget a cui passerà.GotoExpression
Valori restituiti
Oggetto GotoExpression con Kind uguale a Goto, la Target proprietà impostata sul valore specificato e un valore Null da passare all'etichetta di destinazione al passaggio.
Esempio
Nell'esempio seguente viene illustrato come creare un'espressione contenente un GotoExpression oggetto .
// 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).
Si applica a
Goto(LabelTarget, Expression)
Crea un oggetto GotoExpression che rappresenta un'istruzione "vai a". È possibile specificare il valore passato all'etichetta al passaggio.
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
Parametri
- target
- LabelTarget
Oggetto LabelTarget a cui passerà.GotoExpression
- value
- Expression
Valore che verrà passato all'etichetta associata al passaggio.
Valori restituiti
Oggetto GotoExpression con Kind uguale a Goto, la Target proprietà impostata su targete value da passare all'etichetta di destinazione al momento del salto.