Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Expression.NewArrayBounds Method (Type, IEnumerable<Expression>)

Creates a NewArrayExpression that represents creating an array that has a specified rank.

Namespace:  System.Linq.Expressions
Assembly:  System.Core (in System.Core.dll)
public static NewArrayExpression NewArrayBounds(
	Type type,
	IEnumerable<Expression> bounds
)

Parameters

type
Type: System.Type
A Type that represents the element type of the array.
bounds
Type: System.Collections.Generic.IEnumerable<Expression>
An IEnumerable<T> that contains Expression objects to use to populate the Expressions collection.

Return Value

Type: System.Linq.Expressions.NewArrayExpression
A NewArrayExpression that has the NodeType property equal to NewArrayBounds and the Expressions property set to the specified value.
ExceptionCondition
ArgumentNullException

type or bounds is null.

-or-

An element of bounds is null.

ArgumentException

The Type property of an element of bounds does not represent an integral type.

The Type property of the resulting NewArrayExpression represents an array type whose rank is equal to the length of bounds and whose element type is type.

The Type property of each element of bounds must represent an integral type.

The following example demonstrates how to use the NewArrayBounds method to create an expression tree that represents creating a string array that has a rank of 2.


// 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)


.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.