Expression.Break メソッド

定義

break ステートメントを表す GotoExpression を作成します。

オーバーロード

名前 説明
Break(LabelTarget)

break ステートメントを表す GotoExpression を作成します。

Break(LabelTarget, Expression)

break ステートメントを表す GotoExpression を作成します。 ジャンプ時にラベルに渡される値を指定できます。

Break(LabelTarget, Type)

指定した型の break ステートメントを表す GotoExpression を作成します。

Break(LabelTarget, Expression, Type)

指定した型の break ステートメントを表す GotoExpression を作成します。 ジャンプ時にラベルに渡される値を指定できます。

Break(LabelTarget)

ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs

break ステートメントを表す GotoExpression を作成します。

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

パラメーター

target
LabelTarget

LabelTargetがジャンプするGotoExpression

返品

GotoExpression Break と等しいKindTarget プロパティが target に設定され、ジャンプ時にターゲット ラベルに渡される null 値。

次の例では、LoopExpression メソッドを使用する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

適用対象

Break(LabelTarget, Expression)

ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs

break ステートメントを表す GotoExpression を作成します。 ジャンプ時にラベルに渡される値を指定できます。

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

パラメーター

target
LabelTarget

LabelTargetがジャンプするGotoExpression

value
Expression

ジャンプ時に関連付けられているラベルに渡される値。

返品

GotoExpression Break と等しいKindTarget プロパティを target に設定し、ジャンプ時にターゲット ラベルに渡すvalue

適用対象

Break(LabelTarget, Type)

ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs

指定した型の break ステートメントを表す GotoExpression を作成します。

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

パラメーター

target
LabelTarget

LabelTargetがジャンプするGotoExpression

type
Type

Type プロパティを等しい値に設定するType

返品

Break と等しいGotoExpressionKind プロパティが Target に設定され、target プロパティが Type に設定されているtype

適用対象

Break(LabelTarget, Expression, Type)

ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs
ソース:
GotoExpression.cs

指定した型の break ステートメントを表す GotoExpression を作成します。 ジャンプ時にラベルに渡される値を指定できます。

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

パラメーター

target
LabelTarget

LabelTargetがジャンプするGotoExpression

value
Expression

ジャンプ時に関連付けられているラベルに渡される値。

type
Type

Type プロパティを等しい値に設定するType

返品

break と等しいGotoExpressionを持つKindTarget プロパティを target に設定し、Type プロパティを type に設定し、ジャンプ時にターゲット ラベルに渡すvalue

適用対象