Expression.Goto Méthode

Définition

Crée un GotoExpression qui représente une instruction GoTo.

Surcharges

Goto(LabelTarget, Expression, Type)

Crée un GotoExpression qui représente une instruction GoTo avec le type spécifié. La valeur passée à l'étiquette au moment du saut peut être spécifiée.

Goto(LabelTarget, Type)

Crée un GotoExpression qui représente une instruction GoTo avec le type spécifié.

Goto(LabelTarget)

Crée un GotoExpression qui représente une instruction GoTo.

Goto(LabelTarget, Expression)

Crée un GotoExpression qui représente une instruction GoTo. La valeur passée à l'étiquette au moment du saut peut être spécifiée.

Goto(LabelTarget, Expression, Type)

Source:
GotoExpression.cs
Source:
GotoExpression.cs
Source:
GotoExpression.cs

Crée un GotoExpression qui représente une instruction GoTo avec le type spécifié. La valeur passée à l'étiquette au moment du saut peut être spécifiée.

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

Paramètres

target
LabelTarget

LabelTarget auquel GotoExpression accédera.

value
Expression

Valeur qui sera passée à l'étiquette associée au moment du saut.

type
Type

Type auquel la propriété Type doit être égale.

Retours

GotoExpression avec la propriété Kind égale à GoTo, la propriété Target égale à target, la propriété Type égale à type et value à passer à l'étiquette cible au moment du saut.

S’applique à

Goto(LabelTarget, Type)

Source:
GotoExpression.cs
Source:
GotoExpression.cs
Source:
GotoExpression.cs

Crée un GotoExpression qui représente une instruction GoTo avec le type spécifié.

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

Paramètres

target
LabelTarget

LabelTarget auquel GotoExpression accédera.

type
Type

Type auquel la propriété Type doit être égale.

Retours

GotoExpression avec la propriété Kind égale à GoTo, la propriété Target égale à la valeur spécifiée, la propriété Type égale à type et une valeur Null à passer à l'étiquette cible au moment du saut.

S’applique à

Goto(LabelTarget)

Source:
GotoExpression.cs
Source:
GotoExpression.cs
Source:
GotoExpression.cs

Crée un GotoExpression qui représente une instruction 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

Paramètres

target
LabelTarget

LabelTarget auquel GotoExpression accédera.

Retours

GotoExpression avec la propriété Kind égale à GoTo, la propriété Target égale à la valeur spécifiée et une valeur Null à passer à l'étiquette cible au moment du saut.

Exemples

L’exemple suivant montre comment créer une expression qui contient un GotoExpression objet.

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

S’applique à

Goto(LabelTarget, Expression)

Source:
GotoExpression.cs
Source:
GotoExpression.cs
Source:
GotoExpression.cs

Crée un GotoExpression qui représente une instruction GoTo. La valeur passée à l'étiquette au moment du saut peut être spécifiée.

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

Paramètres

target
LabelTarget

LabelTarget auquel GotoExpression accédera.

value
Expression

Valeur qui sera passée à l'étiquette associée au moment du saut.

Retours

GotoExpression avec la propriété Kind égale à GoTo, la propriété Target égale à target et value à passer à l'étiquette cible au moment du saut.

S’applique à