NewExpression 類別

定義

代表建構函式呼叫。

public ref class NewExpression : System::Linq::Expressions::Expression, System::Linq::Expressions::IArgumentProvider
public ref class NewExpression sealed : System::Linq::Expressions::Expression
public ref class NewExpression : System::Linq::Expressions::Expression
public class NewExpression : System.Linq.Expressions.Expression, System.Linq.Expressions.IArgumentProvider
public sealed class NewExpression : System.Linq.Expressions.Expression
public class NewExpression : System.Linq.Expressions.Expression
type NewExpression = class
    inherit Expression
    interface IArgumentProvider
type NewExpression = class
    inherit Expression
Public Class NewExpression
Inherits Expression
Implements IArgumentProvider
Public NotInheritable Class NewExpression
Inherits Expression
Public Class NewExpression
Inherits Expression
繼承
NewExpression
實作

範例

下列範例會建立 , NewExpression 代表字典物件之新實例的建構。

// Create a NewExpression that represents constructing
// a new instance of Dictionary<int, string>.
System.Linq.Expressions.NewExpression newDictionaryExpression =
    System.Linq.Expressions.Expression.New(typeof(Dictionary<int, string>));

Console.WriteLine(newDictionaryExpression.ToString());

// This code produces the following output:
//
// new Dictionary`2()
' Create a NewExpression that represents constructing
' a new instance of Dictionary(Of Integer, String).
Dim newDictionaryExpression As System.Linq.Expressions.NewExpression = _
    System.Linq.Expressions.Expression.[New]( _
        Type.GetType("System.Collections.Generic.Dictionary`2[System.Int32, System.String]"))

Console.WriteLine(newDictionaryExpression.ToString())

' This code produces the following output:
'
' new Dictionary`2()

備註

New使用 Factory 方法來建立 NewExpression

NodeType物件的 屬性值 NewExpressionNew

屬性

Arguments

取得要傳遞到建構函式的引數。

CanReduce

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

(繼承來源 Expression)
Constructor

取得所呼叫的建構函式。

Members

取得可擷取已使用建構函式引數初始化之欄位值的成員。

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)
Update(IEnumerable<Expression>)

建立類似這個運算式的新運算式,但使用提供的子系。 如果所有子系都相同,則會傳回這個運算式。

VisitChildren(ExpressionVisitor)

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

(繼承來源 Expression)

明確介面實作

IArgumentProvider.ArgumentCount

取得運算式樹狀節點的引數數目。

IArgumentProvider.GetArgument(Int32)

傳回位於索引的引數,如果索引超出範圍則擲回引數。

適用於