NewArrayExpression Sınıf
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Yeni bir dizi oluşturmayı ve 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
Ö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
CanReduce |
Düğümün daha basit bir düğüme indirgenebileceğini gösterir. Bu true değerini 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 NodeTypeNewArrayBoundsNewArrayInitdeğeri 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 |
Bunu Expression temsil eden ifadenin statik türünü alır. |
Type |
Bunu Expression temsil eden ifadenin statik türünü alır. (Devralındığı yer: Expression) |
Yöntemler
Accept(ExpressionVisitor) |
Bu düğüm türü için belirli bir ziyaret yöntemine gönderilir. Örneğin, MethodCallExpression öğesini çağırır VisitMethodCall(MethodCallExpression). |
Accept(ExpressionVisitor) |
Bu düğüm türü için belirli bir ziyaret yöntemine gönderilir. Örneğin, MethodCallExpression öğesini çağırır VisitMethodCall(MethodCallExpression). (Devralındığı yer: Expression) |
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() |
Type Geçerli örneğini alır. (Devralındığı yer: Object) |
MemberwiseClone() |
Geçerli Objectöğesinin sığ 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, azaltılması 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, azaltılması 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ğil) küçültür veya zaten bilinen bir türse yalnızca ifadeyi döndürür. (Devralındığı yer: Expression) |
ToString() |
öğesinin metinsel gösterimini Expressiondö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. Düğüm azaltılabilir değilse yöntemi bir özel durum oluşturur. (Devralındığı yer: Expression) |