NewArrayExpression Sınıf

Tanım

Yeni dizi oluşturmayı ve büyük olasılıkla yeni dizinin öğelerini başlatmayı temsil eder.

public ref class NewArrayExpression : System::Linq::Expressions::Expression
public ref class NewArrayExpression sealed : System::Linq::Expressions::Expression
public class NewArrayExpression : System.Linq.Expressions.Expression
public sealed class NewArrayExpression : System.Linq.Expressions.Expression
type NewArrayExpression = class
    inherit Expression
Public Class NewArrayExpression
Inherits Expression
Public NotInheritable Class NewArrayExpression
Inherits Expression
Devralma
NewArrayExpression

Örnekler

Aşağıdaki örnek, tek boyutlu bir NewArrayExpression dize dizisi oluşturmayı ve başlatmayı temsil eden bir nesne oluşturur.

List<System.Linq.Expressions.Expression> trees =
    new List<System.Linq.Expressions.Expression>()
        { System.Linq.Expressions.Expression.Constant("oak"),
          System.Linq.Expressions.Expression.Constant("fir"),
          System.Linq.Expressions.Expression.Constant("spruce"),
          System.Linq.Expressions.Expression.Constant("alder") };

// Create an expression tree that represents creating and
// initializing a one-dimensional array of type string.
System.Linq.Expressions.NewArrayExpression newArrayExpression =
    System.Linq.Expressions.Expression.NewArrayInit(typeof(string), trees);

// Output the string representation of the Expression.
Console.WriteLine(newArrayExpression.ToString());

// This code produces the following output:
//
// new [] {"oak", "fir", "spruce", "alder"}
Dim trees As New System.Collections.Generic.List(Of System.Linq.Expressions.Expression) _
        (New System.Linq.Expressions.Expression() _
         {System.Linq.Expressions.Expression.Constant("oak"), _
          System.Linq.Expressions.Expression.Constant("fir"), _
          System.Linq.Expressions.Expression.Constant("spruce"), _
          System.Linq.Expressions.Expression.Constant("alder")})

' Create an expression tree that represents creating and  
' initializing a one-dimensional array of type string.
Dim newArrayExpression As System.Linq.Expressions.NewArrayExpression = _
    System.Linq.Expressions.Expression.NewArrayInit(Type.GetType("System.String"), trees)

' Output the string representation of the Expression.
Console.WriteLine(newArrayExpression.ToString())

' This code produces the following output:
'
' new [] {"oak", "fir", "spruce", "alder"}

Sonraki örnek, iki boyutlu dize NewArrayExpression dizisi oluşturmayı temsil eden bir nesne oluşturur.

// Create an expression tree that represents creating a
// two-dimensional array of type string with bounds [3,2].
System.Linq.Expressions.NewArrayExpression newArrayExpression =
    System.Linq.Expressions.Expression.NewArrayBounds(
            typeof(string),
            System.Linq.Expressions.Expression.Constant(3),
            System.Linq.Expressions.Expression.Constant(2));

// Output the string representation of the Expression.
Console.WriteLine(newArrayExpression.ToString());

// This code produces the following output:
//
// new System.String[,](3, 2)
' Create an expression tree that represents creating a string
' array with rank 2 and bounds (3,2).
Dim newArrayExpression As System.Linq.Expressions.NewArrayExpression = _
    System.Linq.Expressions.Expression.NewArrayBounds( _
            Type.GetType("System.String"), _
            System.Linq.Expressions.Expression.Constant(3), _
            System.Linq.Expressions.Expression.Constant(2))

' Output the string representation of the Expression.
Console.WriteLine(newArrayExpression.ToString())

' This code produces the following output:
'
' new System.String[,](3, 2)

Açıklamalar

Aşağıdaki tabloda, ihtiyacınıza bağlı olarak NodeType oluşturmak NewArrayExpression için kullanabileceğiniz farklı fabrika yöntemleri gösterilmektedir.

NodeType Fabrika Yöntemleri
NewArrayBounds NewArrayBounds
NewArrayInit NewArrayInit

Özellikler

Name Description
CanReduce

Düğümün daha basit bir düğüme indirgenebileceğini gösterir. Bu true döndürürse, azaltılmış formu oluşturmak için Reduce() çağrılabilir.

(Devralındığı yer: Expression)
Expressions

özelliğinin değeri ise dizinin sınırlarını veya özelliğin NewArrayBoundsNewArrayInitdeğeri NodeType ise yeni dizinin öğelerini başlatacak değerleri NodeType alır.

NodeType

Bu Expressiondüğüm türünü alır.

(Devralındığı yer: Expression)
Type

Bu Expression temsil ettiği ifadenin statik türünü alır.

Type

Bu Expression temsil ettiği ifadenin statik türünü alır.

(Devralındığı yer: Expression)

Yöntemler

Name Description
Accept(ExpressionVisitor)

Bu düğüm türü için belirli bir ziyaret yöntemine gönderilir. Örneğin, MethodCallExpressionVisitMethodCall(MethodCallExpression)çağırır.

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
Reduce()

Bu düğümü daha basit bir ifadeye küçültür. CanReduce true döndürürse, bu geçerli bir ifade döndürmelidir. Bu yöntem, azaltması gereken başka bir düğüm döndürebilir.

(Devralındığı yer: Expression)
ReduceAndCheck()

Bu düğümü daha basit bir ifadeye küçültür. CanReduce true döndürürse, bu geçerli bir ifade döndürmelidir. Bu yöntem, azaltması gereken başka bir düğüm döndürebilir.

(Devralındığı yer: Expression)
ReduceExtensions()

İfadeyi bilinen bir düğüm türüne (Uzantı düğümü değildir) küçültür veya zaten bilinen bir türse yalnızca ifadeyi döndürür.

(Devralındığı yer: Expression)
ToString()

Expressionmetinsel gösterimini döndürür.

(Devralındığı yer: Expression)
Update(IEnumerable<Expression>)

Bunun gibi, ancak sağlanan alt öğeleri kullanarak yeni bir ifade oluşturur. Tüm alt öğeler aynıysa, bu ifadeyi döndürür.

VisitChildren(ExpressionVisitor)

Düğümü azaltır ve ardından azaltılmış ifadede ziyaretçi temsilcisini çağırır. Yöntem, düğüm azaltılabilir değilse bir özel durum oluşturur.

(Devralındığı yer: Expression)

Şunlara uygulanır