Expression.Parameter 메서드

정의

식 트리에서 매개 변수나 변수를 식별하는 데 사용할 수 있는 ParameterExpression 노드를 만듭니다.

오버로드

Parameter(Type, String)

식 트리에서 매개 변수나 변수를 식별하는 데 사용할 수 있는 ParameterExpression 노드를 만듭니다.

Parameter(Type)

식 트리에서 매개 변수나 변수를 식별하는 데 사용할 수 있는 ParameterExpression 노드를 만듭니다.

Parameter(Type, String)

식 트리에서 매개 변수나 변수를 식별하는 데 사용할 수 있는 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

ParameterExpression 속성이 NodeType이고 ParameterType 속성이 지정된 값으로 설정된 Name입니다.

예외

type이(가) null인 경우

적용 대상

Parameter(Type)

식 트리에서 매개 변수나 변수를 식별하는 데 사용할 수 있는 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

지정된 이름과 형식의 ParameterExpression 노드입니다.

예제

다음 예제에서는 개체의 ParameterExpression 값을 인쇄 하는 개체를 만드는 MethodCallExpression 방법을 보여 줍니다.

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

적용 대상