Expression.NewArrayInit Yöntem
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.
NewArrayExpression Tek boyutlu bir dizi oluşturmayı ve öğe listesinden başlatmayı temsil eden bir oluşturur.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| NewArrayInit(Type, IEnumerable<Expression>) |
NewArrayExpression Tek boyutlu bir dizi oluşturmayı ve öğe listesinden başlatmayı temsil eden bir oluşturur. |
| NewArrayInit(Type, Expression[]) |
NewArrayExpression Tek boyutlu bir dizi oluşturmayı ve öğe listesinden başlatmayı temsil eden bir oluşturur. |
NewArrayInit(Type, IEnumerable<Expression>)
- Kaynak:
- NewArrayExpression.cs
- Kaynak:
- NewArrayExpression.cs
- Kaynak:
- NewArrayExpression.cs
- Kaynak:
- NewArrayExpression.cs
- Kaynak:
- NewArrayExpression.cs
NewArrayExpression Tek boyutlu bir dizi oluşturmayı ve öğe listesinden başlatmayı temsil eden bir oluşturur.
public:
static System::Linq::Expressions::NewArrayExpression ^ NewArrayInit(Type ^ type, System::Collections::Generic::IEnumerable<System::Linq::Expressions::Expression ^> ^ initializers);
public static System.Linq.Expressions.NewArrayExpression NewArrayInit(Type type, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> initializers);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
public static System.Linq.Expressions.NewArrayExpression NewArrayInit(Type type, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> initializers);
static member NewArrayInit : Type * seq<System.Linq.Expressions.Expression> -> System.Linq.Expressions.NewArrayExpression
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")>]
static member NewArrayInit : Type * seq<System.Linq.Expressions.Expression> -> System.Linq.Expressions.NewArrayExpression
Public Shared Function NewArrayInit (type As Type, initializers As IEnumerable(Of Expression)) As NewArrayExpression
Parametreler
- initializers
- IEnumerable<Expression>
IEnumerable<T> Koleksiyonu doldurmak Expressions için kullanılacak nesneleri içerenExpression.
Döndürülenler
NewArrayExpression özelliğine NodeType eşit NewArrayInit ve Expressions özelliği belirtilen değere ayarlanmış bir.
- Öznitelikler
Özel durumlar
type veya initializers şeklindedir null.
-veya-
öğesinin initializers öğesidir null.
Type öğesinin initializers özelliği, temsil eden türe atanamayan bir türü type temsil eder.
Örnekler
Aşağıdaki örnek, dize ifadeleri listesiyle başlatılan tek boyutlu bir dize dizisi oluşturmayı temsil eden bir ifade ağacı oluşturmak için yönteminin nasıl kullanılacağını NewArrayInit gösterir.
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"}
Açıklamalar
Type her öğesinin initializers özelliği, tarafından temsil edilen typetüre atanabilir bir türü temsil etmelidir, büyük olasılıkla alıntılandıktan sonra.
Uyarı
Bir öğe yalnızca ise typeExpressiontırnak içine alınır. Alıntılama, öğenin bir Quote düğümde sarmalanması anlamına gelir. Sonuçta elde edilen düğüm, özelliği öğesinin initializersöğesi olan bir UnaryExpressionOperand düğümdür.
Sonucun TypeNewArrayExpression özelliği, derecelendirmesi 1 olan ve öğe türü olan bir dizi türünü typetemsil eder.
Şunlara uygulanır
NewArrayInit(Type, Expression[])
- Kaynak:
- NewArrayExpression.cs
- Kaynak:
- NewArrayExpression.cs
- Kaynak:
- NewArrayExpression.cs
- Kaynak:
- NewArrayExpression.cs
- Kaynak:
- NewArrayExpression.cs
NewArrayExpression Tek boyutlu bir dizi oluşturmayı ve öğe listesinden başlatmayı temsil eden bir oluşturur.
public:
static System::Linq::Expressions::NewArrayExpression ^ NewArrayInit(Type ^ type, ... cli::array <System::Linq::Expressions::Expression ^> ^ initializers);
public static System.Linq.Expressions.NewArrayExpression NewArrayInit(Type type, params System.Linq.Expressions.Expression[] initializers);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
public static System.Linq.Expressions.NewArrayExpression NewArrayInit(Type type, params System.Linq.Expressions.Expression[] initializers);
static member NewArrayInit : Type * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.NewArrayExpression
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")>]
static member NewArrayInit : Type * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.NewArrayExpression
Public Shared Function NewArrayInit (type As Type, ParamArray initializers As Expression()) As NewArrayExpression
Parametreler
- initializers
- Expression[]
Koleksiyonu doldurmak Expressions için kullanılacak bir nesne dizisiExpression.
Döndürülenler
NewArrayExpression özelliğine NodeType eşit NewArrayInit ve Expressions özelliği belirtilen değere ayarlanmış bir.
- Öznitelikler
Özel durumlar
type veya initializers şeklindedir null.
-veya-
öğesinin initializers öğesidir null.
Type öğesinin initializers özelliği türüne atanamayan bir türü typetemsil eder.
Örnekler
Aşağıdaki örnek, dize ifadeleri listesiyle başlatılan tek boyutlu bir dize dizisi oluşturmayı temsil eden bir ifade ağacı oluşturmak için yönteminin nasıl kullanılacağını NewArrayInit gösterir.
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"}
Açıklamalar
Type her öğesinin initializers özelliği, tarafından temsil edilen typetüre atanabilir bir türü temsil etmelidir, büyük olasılıkla alıntılandıktan sonra.
Uyarı
Bir öğe yalnızca ise typeExpressiontırnak içine alınır. Alıntılama, öğenin bir Quote düğümde sarmalanması anlamına gelir. Sonuçta elde edilen düğüm, özelliği öğesinin initializersöğesi olan bir UnaryExpressionOperand düğümdür.
Sonucun TypeNewArrayExpression özelliği, derecelendirmesi 1 olan ve öğe türü olan bir dizi türünü typetemsil eder.