Expression.Goto Método

Definição

Cria um GotoExpression que representa uma instrução "go to".

Sobrecargas

Goto(LabelTarget, Expression, Type)

Cria um GotoExpression que representa uma instrução "go to" com o tipo especificado. O valor passado para o rótulo no salto pode ser especificado.

Goto(LabelTarget, Type)

Cria um GotoExpression que representa uma instrução "go to" com o tipo especificado.

Goto(LabelTarget)

Cria um GotoExpression que representa uma instrução "go to".

Goto(LabelTarget, Expression)

Cria um GotoExpression que representa uma instrução "go to". O valor passado para o rótulo no salto pode ser especificado.

Goto(LabelTarget, Expression, Type)

Origem:
GotoExpression.cs
Origem:
GotoExpression.cs
Origem:
GotoExpression.cs

Cria um GotoExpression que representa uma instrução "go to" com o tipo especificado. O valor passado para o rótulo no salto pode ser especificado.

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

O LabelTarget para o qual o GotoExpression irá.

value
Expression

O valor que será passado para o rótulo associado ao saltar.

type
Type

Um Type para definir a propriedade Type igual a ele.

Retornos

Um GotoExpression com Kind igual a Goto, a propriedade Target definida para target, a propriedade Type definida para type e value a ser passado para o rótulo de destino ao saltar.

Aplica-se a

Goto(LabelTarget, Type)

Origem:
GotoExpression.cs
Origem:
GotoExpression.cs
Origem:
GotoExpression.cs

Cria um GotoExpression que representa uma instrução "go to" com o 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

O LabelTarget para o qual o GotoExpression irá.

type
Type

Um Type para definir a propriedade Type igual a ele.

Retornos

Um GotoExpression com Kind igual a Goto, a propriedade Target definida para o valor especificado, a propriedade Type definida para type e um valor nulo a serem passados para o rótulo de destino após saltar.

Aplica-se a

Goto(LabelTarget)

Origem:
GotoExpression.cs
Origem:
GotoExpression.cs
Origem:
GotoExpression.cs

Cria um GotoExpression que representa uma instrução "go to".

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

O LabelTarget para o qual o GotoExpression irá.

Retornos

Um GotoExpression com Kind igual a Goto, a propriedade Target definida para o valor especificado e um valor nulo a ser passado para o rótulo de destino após saltar.

Exemplos

O exemplo a seguir demonstra como criar uma expressão que contém um 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).

Aplica-se a

Goto(LabelTarget, Expression)

Origem:
GotoExpression.cs
Origem:
GotoExpression.cs
Origem:
GotoExpression.cs

Cria um GotoExpression que representa uma instrução "go to". O valor passado para o rótulo no salto pode ser especificado.

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

O LabelTarget para o qual o GotoExpression irá.

value
Expression

O valor que será passado para o rótulo associado ao saltar.

Retornos

Um GotoExpression com Kind igual a Goto, a propriedade Target definida para target e value a ser passado para o rótulo de destino ao saltar.

Aplica-se a