LambdaExpression
LambdaExpression
LambdaExpression
LambdaExpression
Class
定義
ラムダ式を記述します。 これは、.NET メソッド本体に似たコードのブロックをキャプチャします。
public ref class LambdaExpression abstract : System::Linq::Expressions::Expression
public abstract class LambdaExpression : System.Linq.Expressions.Expression
type LambdaExpression = class
inherit Expression
Public MustInherit Class LambdaExpression
Inherits Expression
- 継承
-
LambdaExpressionLambdaExpressionLambdaExpressionLambdaExpression
- 派生
例
次の例では、1 を使用して、渡された引数に追加するラムダ式を表す式を作成する方法、Lambdaメソッド。
// Add the following directive to your file:
// using System.Linq.Expressions;
// A parameter for the lambda expression.
ParameterExpression paramExpr = Expression.Parameter(typeof(int), "arg");
// This expression represents a lambda expression
// that adds 1 to the parameter value.
LambdaExpression lambdaExpr = Expression.Lambda(
Expression.Add(
paramExpr,
Expression.Constant(1)
),
new List<ParameterExpression>() { paramExpr }
);
// Print out the expression.
Console.WriteLine(lambdaExpr);
// Compile and run the lamda expression.
// The value of the parameter is 1.
Console.WriteLine(lambdaExpr.Compile().DynamicInvoke(1));
// This code example produces the following output:
//
// arg => (arg +1)
// 2
' Add the following directive to your file:
' Imports System.Linq.Expressions
' A parameter for the lambda expression.
Dim paramExpr As ParameterExpression = Expression.Parameter(GetType(Integer), "arg")
' This expression represents a lambda expression
' that adds 1 to the parameter value.
Dim lambdaExpr As LambdaExpression = Expression.Lambda(
Expression.Add(
paramExpr,
Expression.Constant(1)
),
New List(Of ParameterExpression)() From {paramExpr}
)
' Print out the expression.
Console.WriteLine(lambdaExpr)
' Compile and run the lamda expression.
' The value of the parameter is 1.
Console.WriteLine(lambdaExpr.Compile().DynamicInvoke(1))
' This code example produces the following output:
'
' arg => (arg +1)
' 2
注釈
LambdaExpression型が式ツリーの形式でのラムダ式を表します。 Expression<TDelegate>型から派生したLambdaExpressionの詳細は、明示的にこともできますをラムダ式を表すラムダ式の型をキャプチャします。 実行時に、ラムダ式を表す式ツリー ノードは常に型のExpression<TDelegate>します。
値、NodeTypeのプロパティをLambdaExpressionはLambdaします。
使用して、Lambda作成するファクトリ メソッドをLambdaExpressionオブジェクト。
プロパティ
Body Body Body Body |
ラムダ式の本体を取得します。 |
CanReduce CanReduce CanReduce CanReduce |
ノードをより単純なノードに変形できることを示します。 これが true を返す場合、Reduce() を呼び出して単純化された形式を生成できます。 (Inherited from Expression) |
Name Name Name Name |
ラムダ式の名前を取得します。 |
NodeType NodeType NodeType NodeType |
この Expression のノード型を返します。 |
Parameters Parameters Parameters Parameters |
ラムダ式のパラメーターを取得します。 |
ReturnType ReturnType ReturnType ReturnType |
ラムダ式の戻り値の型を取得します。 |
TailCall TailCall TailCall TailCall |
ラムダ式が tail 呼び出し最適化を使用してコンパイルされるかどうかを示す値を取得します。 |
Type Type Type Type |
この Expression が表す式の静的な型を取得します。 |
メソッド
適用対象
フィードバック
お客様のご意見をお寄せください。 お寄せいただく内容の種類を選択:
このフィードバック システムは、GitHub Issues を利用して構築されています。 詳しくは、ブログをご覧ください。
フィードバックを読み込んでいます...