Expression.Break Metoda

Definice

Vytvoří představující GotoExpression příkaz break.

Přetížení

Break(LabelTarget)

Vytvoří představující GotoExpression příkaz break.

Break(LabelTarget, Expression)

Vytvoří představující GotoExpression příkaz break. Je možné zadat hodnotu předanou popisku při přeskočení.

Break(LabelTarget, Type)

Vytvoří představující GotoExpression příkaz break se zadaným typem.

Break(LabelTarget, Expression, Type)

Vytvoří představující GotoExpression příkaz break se zadaným typem. Je možné zadat hodnotu předanou popisku při přeskočení.

Break(LabelTarget)

Zdroj:
GotoExpression.cs
Zdroj:
GotoExpression.cs
Zdroj:
GotoExpression.cs

Vytvoří představující GotoExpression příkaz 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 co GotoExpression přeskočí.

Návraty

Vlastnost GotoExpression s Kind hodnotou Break, nastavenou Target na targethodnotu a hodnotou null, která se při přeskočení předá cílovému popisku.

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

Vytvoří představující GotoExpression příkaz break. Je možné zadat hodnotu předanou popisku při přeskočení.

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 co GotoExpression přeskočí.

value
Expression

Hodnota, která se při přeskočení předá přidruženému popisku.

Návraty

Vlastnost GotoExpression se Kind rovná Break, vlastnost nastavená Target na targeta value se předá cílovému popisku při přeskočení.

Platí pro

Break(LabelTarget, Type)

Zdroj:
GotoExpression.cs
Zdroj:
GotoExpression.cs
Zdroj:
GotoExpression.cs

Vytvoří představující GotoExpression příkaz 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 co GotoExpression přeskočí.

type
Type

Pro Type nastavení Type vlastnosti na hodnotu .

Návraty

Vlastnost se GotoExpressionKind rovná přerušení, vlastnost nastavená Target na targeta vlastnost nastavená Type na typehodnotu .

Platí pro

Break(LabelTarget, Expression, Type)

Zdroj:
GotoExpression.cs
Zdroj:
GotoExpression.cs
Zdroj:
GotoExpression.cs

Vytvoří představující GotoExpression příkaz break se zadaným typem. Je možné zadat hodnotu předanou popisku při přeskočení.

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 co GotoExpression přeskočí.

value
Expression

Hodnota, která se při přeskočení předá přidruženému popisku.

type
Type

Pro Type nastavení Type vlastnosti na hodnotu .

Návraty

Vlastnost GotoExpression se Kind rovná Break, vlastnost nastavená Target na target, vlastnost nastavená Type na typea value se předá cílovému popisku při přeskočení.

Platí pro