ParameterExpression 類別
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
代表具名參數運算式。
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
- 繼承
下列範例示範如何使用 方法來建立MethodCallExpression物件,以列印物件的Parameter值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
Parameter使用 Factory 方法來建立 ParameterExpression。
NodeType物件的 屬性值ParameterExpression為 Parameter。
Can |
表示節點可精簡為更簡單的節點。 如果傳回 true,則可呼叫 Reduce() 以產生精簡的形式。 (繼承來源 Expression) |
Is |
表示這是 |
Name |
取得參數或變數的名稱。 |
Node |
傳回這個 Expression 的節點類型。 |
Node |
取得這個 Expression 的節點類型。 (繼承來源 Expression) |
Type |
取得此 Expression 代表之運算式的靜態類型。 |
Type |
取得此 Expression 代表之運算式的靜態類型。 (繼承來源 Expression) |
Accept(Expression |
分派給這個節點類型的特定造訪方法。 例如,MethodCallExpression 會呼叫 VisitMethodCall(MethodCallExpression)。 |
Accept(Expression |
分派給這個節點類型的特定造訪方法。 例如,MethodCallExpression 會呼叫 VisitMethodCall(MethodCallExpression)。 (繼承來源 Expression) |
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
Get |
做為預設雜湊函式。 (繼承來源 Object) |
Get |
取得目前執行個體的 Type。 (繼承來源 Object) |
Memberwise |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
Reduce() |
將這個節點精簡為更簡單的運算式。 如果 CanReduce 傳回 true,則應該傳回有效的運算式。 這個方法可以傳回其他本身必須精簡的節點。 (繼承來源 Expression) |
Reduce |
將這個節點精簡為更簡單的運算式。 如果 CanReduce 傳回 true,則應該傳回有效的運算式。 這個方法可以傳回其他本身必須精簡的節點。 (繼承來源 Expression) |
Reduce |
將運算式精簡為已知的節點類型 (不是 Extension 節點),如果已經是已知的類型,則僅傳回運算式。 (繼承來源 Expression) |
To |
傳回 Expression 的文字表示。 (繼承來源 Expression) |
Visit |
精簡節點,然後呼叫精簡後的運算式上的訪問項委派。 如果節點無法縮減,此方法會擲回例外狀況。 (繼承來源 Expression) |
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |