Expression.Break Yöntem

Tanım

GotoExpression Break deyimini temsil eden bir oluşturur.

Aşırı Yüklemeler

Name Description
Break(LabelTarget)

GotoExpression Break deyimini temsil eden bir oluşturur.

Break(LabelTarget, Expression)

GotoExpression Break deyimini temsil eden bir oluşturur. Atlama sırasında etikete geçirilen değer belirtilebilir.

Break(LabelTarget, Type)

Belirtilen türe sahip bir kesme deyimini temsil eden bir GotoExpression oluşturur.

Break(LabelTarget, Expression, Type)

Belirtilen türe sahip bir kesme deyimini temsil eden bir GotoExpression oluşturur. Atlama sırasında etikete geçirilen değer belirtilebilir.

Break(LabelTarget)

Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs

GotoExpression Break deyimini temsil eden bir oluşturur.

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

Parametreler

target
LabelTarget

Atlayacakları LabelTargetGotoExpression şey.

Döndürülenler

GotoExpression Kesmeye eşit olan Kind bir, Target özelliği olarak targetayarlanır ve atlarken hedef etikete geçirilecek null değer.

Örnekler

Aşağıdaki örnek, yöntemini kullanan bir nesne içeren bir LoopExpression ifadenin Break nasıl oluşturulacağını gösterir.

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

Şunlara uygulanır

Break(LabelTarget, Expression)

Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs

GotoExpression Break deyimini temsil eden bir oluşturur. Atlama sırasında etikete geçirilen değer belirtilebilir.

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

Parametreler

target
LabelTarget

Atlayacakları LabelTargetGotoExpression şey.

value
Expression

Atlama sırasında ilişkili etikete geçirilecek değer.

Döndürülenler

GotoExpression Break değerine eşit olan Kind bir, Target özelliği olarak targetayarlanır ve value atlama sırasında hedef etikete geçirilir.

Şunlara uygulanır

Break(LabelTarget, Type)

Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs

Belirtilen türe sahip bir kesme deyimini temsil eden bir GotoExpression oluşturur.

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

Parametreler

target
LabelTarget

Atlayacakları LabelTargetGotoExpression şey.

type
Type

Özelliğinin Type değerine eşit olarak ayarlanması için birType.

Döndürülenler

Break değerine eşit olan AGotoExpression, Kind özelliği olarakTarget, özelliği ise target olarak Typeayarlanır.type

Şunlara uygulanır

Break(LabelTarget, Expression, Type)

Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs
Kaynak:
GotoExpression.cs

Belirtilen türe sahip bir kesme deyimini temsil eden bir GotoExpression oluşturur. Atlama sırasında etikete geçirilen değer belirtilebilir.

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

Parametreler

target
LabelTarget

Atlayacakları LabelTargetGotoExpression şey.

value
Expression

Atlama sırasında ilişkili etikete geçirilecek değer.

type
Type

Özelliğinin Type değerine eşit olarak ayarlanması için birType.

Döndürülenler

Break değerine eşit olan AGotoExpression, Kind özelliği olarak Targetayarlanır, target özelliği olarak ayarlanır Typeve type atlama sonrasında hedef etikete value geçirilir.

Şunlara uygulanır