Expression.NewArrayBounds 方法

定義

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。

多載

NewArrayBounds(Type, Expression[])

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。

NewArrayBounds(Type, IEnumerable<Expression>)

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。

NewArrayBounds(Type, Expression[])

來源:
NewArrayExpression.cs
來源:
NewArrayExpression.cs
來源:
NewArrayExpression.cs

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。

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,代表陣列的項目類型。

bounds
Expression[]

用以填入 Expression 集合之 Expressions 物件的陣列。

傳回

NewArrayExpression,其 NodeType 屬性等於 NewArrayBounds,而 Expressions 屬性設定為指定的值。

例外狀況

typeboundsnull

-或-

bounds 的項目是 null

bounds 之項目的 Type 屬性不表示整數類資料類型。

範例

下列範例示範如何使用 NewArrayBounds 方法來建立運算式樹狀結構,代表建立具有 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)

備註

產生的 TypeNewArrayExpression 屬性代表的陣列類型,其排名等於 的 bounds 長度,且其專案類型為 type

Type的每個元素 bounds 屬性都必須代表整數型別。

適用於

NewArrayBounds(Type, IEnumerable<Expression>)

來源:
NewArrayExpression.cs
來源:
NewArrayExpression.cs
來源:
NewArrayExpression.cs

建立 NewArrayExpression,其代表建立具有指定之陣序的陣列。

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,代表陣列的項目類型。

bounds
IEnumerable<Expression>

IEnumerable<T>,其中包含用以填入 Expression 集合的 Expressions 物件。

傳回

NewArrayExpression,其 NodeType 屬性等於 NewArrayBounds,而 Expressions 屬性設定為指定的值。

例外狀況

typeboundsnull

-或-

bounds 的項目是 null

bounds 之項目的 Type 屬性不表示整數類資料類型。

範例

下列範例示範如何使用 NewArrayBounds 方法來建立運算式樹狀結構,代表建立具有 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)

備註

產生的 TypeNewArrayExpression 屬性代表的陣列類型,其排名等於 的 bounds 長度,且其專案類型為 type

Type的每個元素 bounds 屬性都必須代表整數型別。

適用於