Expression.NewArrayBounds 方法

定義

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。Creates a NewArrayExpression that represents creating an array that has a specified rank.

多載

NewArrayBounds(Type, Expression[])

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。Creates a NewArrayExpression that represents creating an array that has a specified rank.

NewArrayBounds(Type, IEnumerable<Expression>)

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。Creates a NewArrayExpression that represents creating an array that has a specified rank.

NewArrayBounds(Type, Expression[])

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。Creates a NewArrayExpression that represents creating an array that has a specified rank.

public:
 static System::Linq::Expressions::NewArrayExpression ^ NewArrayBounds(Type ^ type, ... cli::array <System::Linq::Expressions::Expression ^> ^ bounds);
public static System.Linq.Expressions.NewArrayExpression NewArrayBounds (Type type, params System.Linq.Expressions.Expression[] bounds);
static member NewArrayBounds : Type * System.Linq.Expressions.Expression[] -> System.Linq.Expressions.NewArrayExpression
Public Shared Function NewArrayBounds (type As Type, ParamArray bounds As Expression()) As NewArrayExpression

參數

type
Type

Type,代表陣列的項目類型。A Type that represents the element type of the array.

bounds
Expression[]

用以填入 Expression 集合之 Expressions 物件的陣列。An array of Expression objects to use to populate the Expressions collection.

傳回

NewArrayExpression

NewArrayExpression,其 NodeType 屬性等於 NewArrayBounds,而 Expressions 屬性設定為指定的值。A NewArrayExpression that has the NodeType property equal to NewArrayBounds and the Expressions property set to the specified value.

例外狀況

typeboundsnulltype or bounds is null.

-或--or- bounds 的項目是 nullAn element of bounds is null.

bounds 之項目的 Type 屬性不表示整數類資料類型。The Type property of an element of bounds does not represent an integral type.

範例

下列範例示範如何使用 NewArrayBounds 方法來建立運算式樹狀架構,此樹狀結構表示建立的排名為2的字串陣列。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)
' 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)

備註

Type產生的屬性 NewArrayExpression 代表其等級等於 bounds 和其元素類型為之長度的陣列類型 typeThe 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.

Type 每個專案的屬性 bounds 都必須代表整數類資料類型。The Type property of each element of bounds must represent an integral type.

適用於

NewArrayBounds(Type, IEnumerable<Expression>)

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。Creates a NewArrayExpression that represents creating an array that has a specified rank.

public:
 static System::Linq::Expressions::NewArrayExpression ^ NewArrayBounds(Type ^ type, System::Collections::Generic::IEnumerable<System::Linq::Expressions::Expression ^> ^ bounds);
public static System.Linq.Expressions.NewArrayExpression NewArrayBounds (Type type, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> bounds);
static member NewArrayBounds : Type * seq<System.Linq.Expressions.Expression> -> System.Linq.Expressions.NewArrayExpression
Public Shared Function NewArrayBounds (type As Type, bounds As IEnumerable(Of Expression)) As NewArrayExpression

參數

type
Type

Type,代表陣列的項目類型。A Type that represents the element type of the array.

bounds
IEnumerable<Expression>

IEnumerable<T>,其中包含用以填入 Expression 集合的 Expressions 物件。An IEnumerable<T> that contains Expression objects to use to populate the Expressions collection.

傳回

NewArrayExpression

NewArrayExpression,其 NodeType 屬性等於 NewArrayBounds,而 Expressions 屬性設定為指定的值。A NewArrayExpression that has the NodeType property equal to NewArrayBounds and the Expressions property set to the specified value.

例外狀況

typeboundsnulltype or bounds is null.

-或--or- bounds 的項目是 nullAn element of bounds is null.

bounds 之項目的 Type 屬性不表示整數類資料類型。The Type property of an element of bounds does not represent an integral type.

範例

下列範例示範如何使用 NewArrayBounds 方法來建立運算式樹狀架構,此樹狀結構表示建立的排名為2的字串陣列。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)
' 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)

備註

Type產生的屬性 NewArrayExpression 代表其等級等於 bounds 和其元素類型為之長度的陣列類型 typeThe 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.

Type 每個專案的屬性 bounds 都必須代表整數類資料類型。The Type property of each element of bounds must represent an integral type.

適用於