Expression.Goto Método

Definición

Crea un objeto GotoExpression que representa una instrucción GoTo.

Sobrecargas

Goto(LabelTarget, Expression, Type)

Crea un objeto GotoExpression que representa una instrucción "go to" con el tipo especificado. Se puede especificar el valor que se pasa a la etiqueta cuando se produce el salto.

Goto(LabelTarget, Type)

Crea un objeto GotoExpression que representa una instrucción "go to" con el tipo especificado.

Goto(LabelTarget)

Crea un objeto GotoExpression que representa una instrucción GoTo.

Goto(LabelTarget, Expression)

Crea un objeto GotoExpression que representa una instrucción GoTo. Se puede especificar el valor que se pasa a la etiqueta cuando se produce el salto.

Goto(LabelTarget, Expression, Type)

Crea un objeto GotoExpression que representa una instrucción "go to" con el tipo especificado. Se puede especificar el valor que se pasa a la etiqueta cuando se produce el salto.

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

Parámetros

target
LabelTarget

LabelTarget al que saltará GotoExpression.

value
Expression

Valor que se va a pasar a la etiqueta asociada cuando se produzca el salto.

type
Type

Objeto Type en el que se va a establecer la propiedad Type.

Devoluciones

GotoExpression

Objeto GotoExpression con Kind igual a Goto, la propiedad Target establecida en target, la propiedad Type establecida en type y un value que se va a pasar a la etiqueta de destino cuando se produzca el salto.

Se aplica a

Goto(LabelTarget, Type)

Crea un objeto GotoExpression que representa una instrucción "go to" con el tipo especificado.

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

Parámetros

target
LabelTarget

LabelTarget al que saltará GotoExpression.

type
Type

Objeto Type en el que se va a establecer la propiedad Type.

Devoluciones

GotoExpression

Objeto GotoExpression con Kind igual a Goto, la propiedad Target establecida en el valor especificado, la propiedad Type establecida en type y un valor null que se va a pasar a la etiqueta de destino cuando se produzca el salto.

Se aplica a

Goto(LabelTarget)

Crea un objeto GotoExpression que representa una instrucción GoTo.

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

Parámetros

target
LabelTarget

LabelTarget al que saltará GotoExpression.

Devoluciones

GotoExpression

GotoExpression con Kind igual a Goto, la propiedad Target establecida en el valor especificado y un valor null que se pasará a la etiqueta de destino al saltar.

Ejemplos

En el ejemplo siguiente se muestra cómo crear una expresión que contenga un GotoExpression objeto .

// 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).

Se aplica a

Goto(LabelTarget, Expression)

Crea un objeto GotoExpression que representa una instrucción GoTo. Se puede especificar el valor que se pasa a la etiqueta cuando se produce el salto.

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

Parámetros

target
LabelTarget

LabelTarget al que saltará GotoExpression.

value
Expression

Valor que se va a pasar a la etiqueta asociada cuando se produzca el salto.

Devoluciones

GotoExpression

GotoExpression con Kind igual a Goto, la propiedad Target establecida en target y un value que se pasará a la etiqueta de destino al saltar.

Se aplica a