ParameterExpression 類別

定義

代表具名參數運算式。

public ref class ParameterExpression : System::Linq::Expressions::Expression
public ref class ParameterExpression sealed : System::Linq::Expressions::Expression
public class ParameterExpression : System.Linq.Expressions.Expression
public sealed class ParameterExpression : System.Linq.Expressions.Expression
type ParameterExpression = class
    inherit Expression
Public Class ParameterExpression
Inherits Expression
Public NotInheritable Class ParameterExpression
Inherits Expression
繼承
ParameterExpression

範例

下列範例示範如何使用 方法來建立 MethodCallExpression 物件,以列印物件的 ParameterParameterExpression

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

備註

Parameter使用 Factory 方法來建立 ParameterExpression

NodeType物件的 屬性值 ParameterExpressionParameter

屬性

CanReduce

表示節點可精簡為更簡單的節點。 如果傳回 true,則可呼叫 Reduce() 以產生精簡的形式。

(繼承來源 Expression)
IsByRef

表示這是 ParameterExpression 要視為 ByRef 參數。

Name

取得參數或變數的名稱。

NodeType

傳回這個 Expression 的節點類型。

NodeType

取得這個 Expression 的節點類型。

(繼承來源 Expression)
Type

取得此 Expression 代表之運算式的靜態類型。

Type

取得此 Expression 代表之運算式的靜態類型。

(繼承來源 Expression)

方法

Accept(ExpressionVisitor)

分派給這個節點類型的特定造訪方法。 例如,MethodCallExpression 會呼叫 VisitMethodCall(MethodCallExpression)

Accept(ExpressionVisitor)

分派給這個節點類型的特定造訪方法。 例如,MethodCallExpression 會呼叫 VisitMethodCall(MethodCallExpression)

(繼承來源 Expression)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Reduce()

將這個節點精簡為更簡單的運算式。 如果 CanReduce 傳回 true,則應該傳回有效的運算式。 這個方法可以傳回其他本身必須精簡的節點。

(繼承來源 Expression)
ReduceAndCheck()

將這個節點精簡為更簡單的運算式。 如果 CanReduce 傳回 true,則應該傳回有效的運算式。 這個方法可以傳回其他本身必須精簡的節點。

(繼承來源 Expression)
ReduceExtensions()

將運算式精簡為已知的節點類型 (不是 Extension 節點),如果已經是已知的類型,則僅傳回運算式。

(繼承來源 Expression)
ToString()

傳回 Expression 的文字表示。

(繼承來源 Expression)
VisitChildren(ExpressionVisitor)

精簡節點,然後呼叫精簡後的運算式上的訪問項委派。 如果節點無法縮減,此方法會擲回例外狀況。

(繼承來源 Expression)

適用於