NewArrayExpression Class
Represents creating a new array and possibly initializing the elements of the new array.
Assembly: System.Core (in System.Core.dll)
The following table shows the different factory methods that you can use to create a NewArrayExpression depending on the NodeType you require.
Factory Methods | |
|---|---|
The following example creates a NewArrayExpression object that represents creating and initializing a one-dimensional array of strings.
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"}
The next example creates a NewArrayExpression object that represents creating a two-dimensional array of strings.
' 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)
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.