Expression.Return Metoda

Definicja

Tworzy reprezentującą instrukcję GotoExpression return.

Przeciążenia

Return(LabelTarget)

Tworzy reprezentującą instrukcję GotoExpression return.

Return(LabelTarget, Expression)

Tworzy reprezentującą instrukcję GotoExpression return. Można określić wartość przekazaną do etykiety po skoku.

Return(LabelTarget, Type)

Tworzy reprezentację GotoExpression instrukcji return z określonym typem.

Return(LabelTarget, Expression, Type)

Tworzy reprezentację GotoExpression instrukcji return z określonym typem. Można określić wartość przekazaną do etykiety po skoku.

Return(LabelTarget)

Źródło:
GotoExpression.cs
Źródło:
GotoExpression.cs
Źródło:
GotoExpression.cs

Tworzy reprezentującą instrukcję GotoExpression return.

public:
 static System::Linq::Expressions::GotoExpression ^ Return(System::Linq::Expressions::LabelTarget ^ target);
public static System.Linq.Expressions.GotoExpression Return (System.Linq.Expressions.LabelTarget target);
static member Return : System.Linq.Expressions.LabelTarget -> System.Linq.Expressions.GotoExpression
Public Shared Function Return (target As LabelTarget) As GotoExpression

Parametry

target
LabelTarget

To LabelTarget , do którego GotoExpression będzie skakać.

Zwraca

Element GotoExpression o Kind wartości równej Target Return, właściwość ustawiona na targetwartość i wartość null, która ma zostać przekazana do etykiety docelowej po skoku.

Dotyczy

Return(LabelTarget, Expression)

Źródło:
GotoExpression.cs
Źródło:
GotoExpression.cs
Źródło:
GotoExpression.cs

Tworzy reprezentującą instrukcję GotoExpression return. Można określić wartość przekazaną do etykiety po skoku.

public:
 static System::Linq::Expressions::GotoExpression ^ Return(System::Linq::Expressions::LabelTarget ^ target, System::Linq::Expressions::Expression ^ value);
public static System.Linq.Expressions.GotoExpression Return (System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression value);
public static System.Linq.Expressions.GotoExpression Return (System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression? value);
static member Return : System.Linq.Expressions.LabelTarget * System.Linq.Expressions.Expression -> System.Linq.Expressions.GotoExpression
Public Shared Function Return (target As LabelTarget, value As Expression) As GotoExpression

Parametry

target
LabelTarget

To LabelTarget , do którego GotoExpression będzie skakać.

value
Expression

Wartość, która zostanie przekazana do skojarzonej etykiety po przejściu.

Zwraca

Wartość z GotoExpression wartością Kind Kontynuuj właściwość ustawiona Target na target, a value następnie przekazana do etykiety docelowej po przejściu.

Przykłady

W poniższym przykładzie pokazano, jak utworzyć wyrażenie zawierające metodę Return .

// Add the following directive to the file:
// using System.Linq.Expressions;

// A label expression of the void type that is the target for Expression.Return().
LabelTarget returnTarget = Expression.Label();

// This block contains a GotoExpression that represents a return statement with no value.
// 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("Return")),
        Expression.Return(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:
//
// Return

// "Other Work" is not printed because
// the Return expression transfers execution from Expression.Return(returnTarget)
// to Expression.Label(returnTarget).
' Add the following directive to the file:
' Imports System.Linq.Expressions  

' A label expression of the void type that is the target for Expression.Return().
Dim returnTarget As LabelTarget = Expression.Label()

' This block contains a GotoExpression that represents a return statement with no value.
' 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("Return")),
          Expression.Return(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:
'
' Return

' "Other Work" is not printed because 
' the Return expression transfers execution from Return(returnTarget)
' to Expression.Label(returnTarget).

Dotyczy

Return(LabelTarget, Type)

Źródło:
GotoExpression.cs
Źródło:
GotoExpression.cs
Źródło:
GotoExpression.cs

Tworzy reprezentację GotoExpression instrukcji return z określonym typem.

public:
 static System::Linq::Expressions::GotoExpression ^ Return(System::Linq::Expressions::LabelTarget ^ target, Type ^ type);
public static System.Linq.Expressions.GotoExpression Return (System.Linq.Expressions.LabelTarget target, Type type);
static member Return : System.Linq.Expressions.LabelTarget * Type -> System.Linq.Expressions.GotoExpression
Public Shared Function Return (target As LabelTarget, type As Type) As GotoExpression

Parametry

target
LabelTarget

To LabelTarget , do którego GotoExpression będzie skakać.

type
Type

Element , Type aby ustawić właściwość równą Type .

Zwraca

Element GotoExpression o Kind wartości równej Target Return, właściwość ustawiona na target, Type właściwość ustawiona na type, i wartość null, która ma zostać przekazana do etykiety docelowej po skoku.

Dotyczy

Return(LabelTarget, Expression, Type)

Źródło:
GotoExpression.cs
Źródło:
GotoExpression.cs
Źródło:
GotoExpression.cs

Tworzy reprezentację GotoExpression instrukcji return z określonym typem. Można określić wartość przekazaną do etykiety po skoku.

public:
 static System::Linq::Expressions::GotoExpression ^ Return(System::Linq::Expressions::LabelTarget ^ target, System::Linq::Expressions::Expression ^ value, Type ^ type);
public static System.Linq.Expressions.GotoExpression Return (System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression value, Type type);
public static System.Linq.Expressions.GotoExpression Return (System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression? value, Type type);
static member Return : System.Linq.Expressions.LabelTarget * System.Linq.Expressions.Expression * Type -> System.Linq.Expressions.GotoExpression
Public Shared Function Return (target As LabelTarget, value As Expression, type As Type) As GotoExpression

Parametry

target
LabelTarget

To LabelTarget , do którego GotoExpression będzie skakać.

value
Expression

Wartość, która zostanie przekazana do skojarzonej etykiety po przejściu.

type
Type

Element , Type aby ustawić właściwość równą Type .

Zwraca

Wartość z KindGotoExpression wartością Kontynuuj Target właściwość ustawiona na target, Type właściwość ustawiona na type, a value następnie przekazana do etykiety docelowej po skoku.

Dotyczy