Expression.Break Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Vytvoří reprezentaci GotoExpression příkazu break.
Přetížení
| Name | Description |
|---|---|
| Break(LabelTarget) |
Vytvoří reprezentaci GotoExpression příkazu break. |
| Break(LabelTarget, Expression) |
Vytvoří reprezentaci GotoExpression příkazu break. Hodnotu předanou popisku při přeskakování je možné zadat. |
| Break(LabelTarget, Type) |
Vytvoří reprezentaci GotoExpression příkazu break se zadaným typem. |
| Break(LabelTarget, Expression, Type) |
Vytvoří reprezentaci GotoExpression příkazu break se zadaným typem. Hodnotu předanou popisku při přeskakování je možné zadat. |
Break(LabelTarget)
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
Vytvoří reprezentaci GotoExpression příkazu break.
public:
static System::Linq::Expressions::GotoExpression ^ Break(System::Linq::Expressions::LabelTarget ^ target);
public static System.Linq.Expressions.GotoExpression Break(System.Linq.Expressions.LabelTarget target);
static member Break : System.Linq.Expressions.LabelTarget -> System.Linq.Expressions.GotoExpression
Public Shared Function Break (target As LabelTarget) As GotoExpression
Parametry
- target
- LabelTarget
To LabelTarget , na GotoExpression co se bude skočit.
Návraty
A GotoExpression se Kind rovná Break, Target vlastnost nastavena na targeta null hodnotu, která se má předat cílovému popisku při skoku.
Příklady
Následující příklad ukazuje, jak vytvořit výraz, který obsahuje LoopExpression objekt, který používá metodu Break .
// Add the following directive to the file:
// using System.Linq.Expressions;
// Creating a parameter expression.
ParameterExpression value = Expression.Parameter(typeof(int), "value");
// Creating an expression to hold a local variable.
ParameterExpression result = Expression.Parameter(typeof(int), "result");
// Creating a label to jump to from a loop.
LabelTarget label = Expression.Label(typeof(int));
// Creating a method body.
BlockExpression block = Expression.Block(
new[] { result },
Expression.Assign(result, Expression.Constant(1)),
Expression.Loop(
Expression.IfThenElse(
Expression.GreaterThan(value, Expression.Constant(1)),
Expression.MultiplyAssign(result,
Expression.PostDecrementAssign(value)),
Expression.Break(label, result)
),
label
)
);
// Compile and run an expression tree.
int factorial = Expression.Lambda<Func<int, int>>(block, value).Compile()(5);
Console.WriteLine(factorial);
// This code example produces the following output:
//
// 120
' Add the following directive to the file:
' Imports System.Linq.Expressions
' Creating a parameter expression.
Dim value As ParameterExpression =
Expression.Parameter(GetType(Integer), "value")
' Creating an expression to hold a local variable.
Dim result As ParameterExpression =
Expression.Parameter(GetType(Integer), "result")
' Creating a label to jump to from a loop.
Dim label As LabelTarget = Expression.Label(GetType(Integer))
' Creating a method body.
Dim block As BlockExpression = Expression.Block(
New ParameterExpression() {result},
Expression.Assign(result, Expression.Constant(1)),
Expression.Loop(
Expression.IfThenElse(
Expression.GreaterThan(value, Expression.Constant(1)),
Expression.MultiplyAssign(result,
Expression.PostDecrementAssign(value)),
Expression.Break(label, result)
),
label
)
)
' Compile an expression tree and return a delegate.
Dim factorial As Integer =
Expression.Lambda(Of Func(Of Integer, Integer))(block, value).Compile()(5)
Console.WriteLine(factorial)
' This code example produces the following output:
'
' 120
Platí pro
Break(LabelTarget, Expression)
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
Vytvoří reprezentaci GotoExpression příkazu break. Hodnotu předanou popisku při přeskakování je možné zadat.
public:
static System::Linq::Expressions::GotoExpression ^ Break(System::Linq::Expressions::LabelTarget ^ target, System::Linq::Expressions::Expression ^ value);
public static System.Linq.Expressions.GotoExpression Break(System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression value);
public static System.Linq.Expressions.GotoExpression Break(System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression? value);
static member Break : System.Linq.Expressions.LabelTarget * System.Linq.Expressions.Expression -> System.Linq.Expressions.GotoExpression
Public Shared Function Break (target As LabelTarget, value As Expression) As GotoExpression
Parametry
- target
- LabelTarget
To LabelTarget , na GotoExpression co se bude skočit.
- value
- Expression
Hodnota, která se předá přidruženému popisku při skoku.
Návraty
A GotoExpression se Kind rovná Break, Target vlastnost nastavena na targeta value být předána cílovému popisku při skoku.
Platí pro
Break(LabelTarget, Type)
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
Vytvoří reprezentaci GotoExpression příkazu break se zadaným typem.
public:
static System::Linq::Expressions::GotoExpression ^ Break(System::Linq::Expressions::LabelTarget ^ target, Type ^ type);
public static System.Linq.Expressions.GotoExpression Break(System.Linq.Expressions.LabelTarget target, Type type);
static member Break : System.Linq.Expressions.LabelTarget * Type -> System.Linq.Expressions.GotoExpression
Public Shared Function Break (target As LabelTarget, type As Type) As GotoExpression
Parametry
- target
- LabelTarget
To LabelTarget , na GotoExpression co se bude skočit.
Návraty
A GotoExpression se Kind rovná Break, Target vlastnost nastavena na targeta Type vlastnost nastavena na type.
Platí pro
Break(LabelTarget, Expression, Type)
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
- Zdroj:
- GotoExpression.cs
Vytvoří reprezentaci GotoExpression příkazu break se zadaným typem. Hodnotu předanou popisku při přeskakování je možné zadat.
public:
static System::Linq::Expressions::GotoExpression ^ Break(System::Linq::Expressions::LabelTarget ^ target, System::Linq::Expressions::Expression ^ value, Type ^ type);
public static System.Linq.Expressions.GotoExpression Break(System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression value, Type type);
public static System.Linq.Expressions.GotoExpression Break(System.Linq.Expressions.LabelTarget target, System.Linq.Expressions.Expression? value, Type type);
static member Break : System.Linq.Expressions.LabelTarget * System.Linq.Expressions.Expression * Type -> System.Linq.Expressions.GotoExpression
Public Shared Function Break (target As LabelTarget, value As Expression, type As Type) As GotoExpression
Parametry
- target
- LabelTarget
To LabelTarget , na GotoExpression co se bude skočit.
- value
- Expression
Hodnota, která se předá přidruženému popisku při skoku.
Návraty
A GotoExpression se Kind rovná Break, Target vlastnost nastavena na target, Type vlastnost nastavena na typea value být předána cílovému popisku při skoku.