Expression.Goto Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Membuat pernyataan "buka" yang GotoExpression mewakili.
Overload
Goto(LabelTarget, Expression, Type) |
GotoExpression Membuat pernyataan "buka" yang mewakili dengan jenis yang ditentukan. Nilai yang diteruskan ke label saat melompat dapat ditentukan. |
Goto(LabelTarget, Type) |
GotoExpression Membuat pernyataan "buka" yang mewakili dengan jenis yang ditentukan. |
Goto(LabelTarget) |
Membuat pernyataan "buka" yang GotoExpression mewakili. |
Goto(LabelTarget, Expression) |
Membuat pernyataan "buka" yang GotoExpression mewakili. Nilai yang diteruskan ke label saat melompat dapat ditentukan. |
Goto(LabelTarget, Expression, Type)
- Sumber:
- GotoExpression.cs
- Sumber:
- GotoExpression.cs
- Sumber:
- GotoExpression.cs
GotoExpression Membuat pernyataan "buka" yang mewakili dengan jenis yang ditentukan. Nilai yang diteruskan ke label saat melompat dapat ditentukan.
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
Parameter
- target
- LabelTarget
Yang LabelTargetGotoExpression akan melompat ke.
- value
- Expression
Nilai yang akan diteruskan ke label terkait saat melompat.
Mengembalikan
GotoExpression dengan sama dengan Kind Goto, Target properti diatur ke target
, Type properti diatur ke type
, dan value
akan diteruskan ke label target saat melompat.
Berlaku untuk
Goto(LabelTarget, Type)
- Sumber:
- GotoExpression.cs
- Sumber:
- GotoExpression.cs
- Sumber:
- GotoExpression.cs
GotoExpression Membuat pernyataan "buka" yang mewakili dengan jenis yang ditentukan.
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
Parameter
- target
- LabelTarget
Yang LabelTargetGotoExpression akan melompat ke.
Mengembalikan
GotoExpression dengan sama dengan Kind Goto, Target properti diatur ke nilai yang ditentukan, Type properti diatur ke type
, dan nilai null untuk diteruskan ke label target saat melompat.
Berlaku untuk
Goto(LabelTarget)
- Sumber:
- GotoExpression.cs
- Sumber:
- GotoExpression.cs
- Sumber:
- GotoExpression.cs
Membuat pernyataan "buka" yang GotoExpression mewakili.
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
Parameter
- target
- LabelTarget
Yang LabelTargetGotoExpression akan melompat ke.
Mengembalikan
GotoExpression dengan sama dengan Kind Goto, Target properti diatur ke nilai yang ditentukan, dan nilai null untuk diteruskan ke label target saat melompat.
Contoh
Contoh berikut menunjukkan cara membuat ekspresi yang berisi GotoExpression objek .
// 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).
Berlaku untuk
Goto(LabelTarget, Expression)
- Sumber:
- GotoExpression.cs
- Sumber:
- GotoExpression.cs
- Sumber:
- GotoExpression.cs
Membuat pernyataan "buka" yang GotoExpression mewakili. Nilai yang diteruskan ke label saat melompat dapat ditentukan.
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
Parameter
- target
- LabelTarget
Yang LabelTargetGotoExpression akan melompat ke.
- value
- Expression
Nilai yang akan diteruskan ke label terkait saat melompat.
Mengembalikan
GotoExpression dengan sama dengan Kind Goto, Target properti diatur ke target
, dan value
akan diteruskan ke label target saat melompat.