Expression.Goto Methode

Definitie

Hiermee maakt u een GotoExpression weergave van een 'ga naar'-instructie.

Overloads

Name Description
Goto(LabelTarget, Expression, Type)

Hiermee maakt u een GotoExpression weergave van een 'go to'-instructie met het opgegeven type. De waarde die bij het springen aan het label wordt doorgegeven, kan worden opgegeven.

Goto(LabelTarget, Type)

Hiermee maakt u een GotoExpression weergave van een 'go to'-instructie met het opgegeven type.

Goto(LabelTarget)

Hiermee maakt u een GotoExpression weergave van een 'ga naar'-instructie.

Goto(LabelTarget, Expression)

Hiermee maakt u een GotoExpression weergave van een 'ga naar'-instructie. De waarde die bij het springen aan het label wordt doorgegeven, kan worden opgegeven.

Goto(LabelTarget, Expression, Type)

Hiermee maakt u een GotoExpression weergave van een 'go to'-instructie met het opgegeven type. De waarde die bij het springen aan het label wordt doorgegeven, kan worden opgegeven.

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

Parameters

target
LabelTarget

De LabelTarget die de GotoExpression zal springen.

value
Expression

De waarde die wordt doorgegeven aan het bijbehorende label bij het springen.

type
Type

Een Type om de Type eigenschap in te stellen die gelijk is aan.

Retouren

Een GotoExpression met Kind gelijk aan Goto, de Target eigenschap ingesteld op target, de Type eigenschap ingesteld op typeen value moet worden doorgegeven aan het doellabel bij het springen.

Van toepassing op

Goto(LabelTarget, Type)

Hiermee maakt u een GotoExpression weergave van een 'go to'-instructie met het opgegeven type.

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

Parameters

target
LabelTarget

De LabelTarget die de GotoExpression zal springen.

type
Type

Een Type om de Type eigenschap in te stellen die gelijk is aan.

Retouren

Een GotoExpression met Kind gelijk aan Goto, de Target eigenschap ingesteld op de opgegeven waarde, de Type eigenschap ingesteld op typeen een null-waarde die moet worden doorgegeven aan het doellabel bij het springen.

Van toepassing op

Goto(LabelTarget)

Hiermee maakt u een GotoExpression weergave van een 'ga naar'-instructie.

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

Parameters

target
LabelTarget

De LabelTarget die de GotoExpression zal springen.

Retouren

Een GotoExpression met Kind gelijk aan Goto, de Target eigenschap die is ingesteld op de opgegeven waarde en een null-waarde die moet worden doorgegeven aan het doellabel bij het springen.

Voorbeelden

In het volgende voorbeeld ziet u hoe u een expressie maakt die een GotoExpression object bevat.

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

Van toepassing op

Goto(LabelTarget, Expression)

Hiermee maakt u een GotoExpression weergave van een 'ga naar'-instructie. De waarde die bij het springen aan het label wordt doorgegeven, kan worden opgegeven.

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

Parameters

target
LabelTarget

De LabelTarget die de GotoExpression zal springen.

value
Expression

De waarde die wordt doorgegeven aan het bijbehorende label bij het springen.

Retouren

Een GotoExpression met Kind gelijk aan Goto, de Target eigenschap ingesteld op targeten value moet worden doorgegeven aan het doellabel bij het springen.

Van toepassing op