Expression.Parameter メソッド

定義

式ツリー内のパラメーターまたは変数を識別するために使用できる ParameterExpression ノードを作成します。

オーバーロード

名前 説明
Parameter(Type, String)

式ツリー内のパラメーターまたは変数を識別するために使用できる ParameterExpression ノードを作成します。

Parameter(Type)

式ツリー内のパラメーターまたは変数を識別するために使用できる ParameterExpression ノードを作成します。

Parameter(Type, String)

ソース:
ParameterExpression.cs
ソース:
ParameterExpression.cs
ソース:
ParameterExpression.cs
ソース:
ParameterExpression.cs
ソース:
ParameterExpression.cs

式ツリー内のパラメーターまたは変数を識別するために使用できる ParameterExpression ノードを作成します。

public:
 static System::Linq::Expressions::ParameterExpression ^ Parameter(Type ^ type, System::String ^ name);
public static System.Linq.Expressions.ParameterExpression Parameter(Type type, string name);
public static System.Linq.Expressions.ParameterExpression Parameter(Type type, string? name);
static member Parameter : Type * string -> System.Linq.Expressions.ParameterExpression
Public Shared Function Parameter (type As Type, name As String) As ParameterExpression

パラメーター

type
Type

パラメーターまたは変数の型。

name
String

デバッグまたは印刷目的でのみ使用されるパラメーターまたは変数の名前。

返品

ParameterExpression プロパティが NodeType と等しく、ParameterプロパティとTypeプロパティが指定した値に設定されているName

例外

typenullです。

適用対象

Parameter(Type)

ソース:
ParameterExpression.cs
ソース:
ParameterExpression.cs
ソース:
ParameterExpression.cs
ソース:
ParameterExpression.cs
ソース:
ParameterExpression.cs

式ツリー内のパラメーターまたは変数を識別するために使用できる ParameterExpression ノードを作成します。

public:
 static System::Linq::Expressions::ParameterExpression ^ Parameter(Type ^ type);
public static System.Linq.Expressions.ParameterExpression Parameter(Type type);
static member Parameter : Type -> System.Linq.Expressions.ParameterExpression
Public Shared Function Parameter (type As Type) As ParameterExpression

パラメーター

type
Type

パラメーターまたは変数の型。

返品

指定した名前と型を持つ ParameterExpression ノード。

次の例では、MethodCallExpression オブジェクトの値を出力するParameterExpression オブジェクトを作成する方法を示します。

// Add the following directive to the file:
// using System.Linq.Expressions;

// Creating a parameter for the expression tree.
ParameterExpression param = Expression.Parameter(typeof(int));

// Creating an expression for the method call and specifying its parameter.
MethodCallExpression methodCall = Expression.Call(
    typeof(Console).GetMethod("WriteLine", new Type[] { typeof(int) }),
    param
);

// The following statement first creates an expression tree,
// then compiles it, and then runs it.
Expression.Lambda<Action<int>>(
    methodCall,
    new ParameterExpression[] { param }
).Compile()(10);

// This code example produces the following output:
//
// 10
' Add the following directive to the file:
' Imports System.Linq.Expressions 

' Creating a parameter for the expression tree.
Dim param As ParameterExpression = Expression.Parameter(GetType(Integer))

' Creating an expression for the method call and specifying its parameter.
Dim methodCall As MethodCallExpression = Expression.Call(
        GetType(Console).GetMethod("WriteLine", New Type() {GetType(Integer)}),
        param
    )

' Compiling and invoking the methodCall expression.
Expression.Lambda(Of Action(Of Integer))(
    methodCall,
    New ParameterExpression() {param}
).Compile()(10)
' This code example produces the following output:
'
' 10

適用対象