Expression.NewArrayBounds Metod

Definition

Skapar en NewArrayExpression som representerar skapandet av en matris som har en angiven rangordning.

Överlagringar

Name Description
NewArrayBounds(Type, Expression[])

Skapar en NewArrayExpression som representerar skapandet av en matris som har en angiven rangordning.

NewArrayBounds(Type, IEnumerable<Expression>)

Skapar en NewArrayExpression som representerar skapandet av en matris som har en angiven rangordning.

NewArrayBounds(Type, Expression[])

Skapar en NewArrayExpression som representerar skapandet av en matris som har en angiven rangordning.

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

Parametrar

type
Type

En Type som representerar matrisens elementtyp.

bounds
Expression[]

En matris med Expression objekt som ska användas för att fylla samlingen Expressions .

Returer

En NewArrayExpression som har egenskapen NodeType lika med NewArrayBounds och egenskapen Expressions inställd på det angivna värdet.

Undantag

type eller bounds är null.

-eller-

Ett element i bounds är null.

Egenskapen Type för ett element i bounds representerar inte en integrerad typ.

Exempel

I följande exempel visas hur du använder NewArrayBounds metoden för att skapa ett uttrycksträd som representerar skapandet av en strängmatris som har rangordningen 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)

Kommentarer

Egenskapen Type för resultatet NewArrayExpression representerar en matristyp vars rang är lika med längden bounds på och vars elementtyp är type.

Egenskapen Type för varje element bounds i måste representera en integrerad typ.

Gäller för

NewArrayBounds(Type, IEnumerable<Expression>)

Skapar en NewArrayExpression som representerar skapandet av en matris som har en angiven rangordning.

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

Parametrar

type
Type

En Type som representerar matrisens elementtyp.

bounds
IEnumerable<Expression>

En IEnumerable<T> som innehåller Expression objekt som ska användas för att fylla samlingen Expressions .

Returer

En NewArrayExpression som har egenskapen NodeType lika med NewArrayBounds och egenskapen Expressions inställd på det angivna värdet.

Undantag

type eller bounds är null.

-eller-

Ett element i bounds är null.

Egenskapen Type för ett element i bounds representerar inte en integrerad typ.

Exempel

I följande exempel visas hur du använder NewArrayBounds metoden för att skapa ett uttrycksträd som representerar skapandet av en strängmatris som har rangordningen 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)

Kommentarer

Egenskapen Type för resultatet NewArrayExpression representerar en matristyp vars rang är lika med längden bounds på och vars elementtyp är type.

Egenskapen Type för varje element bounds i måste representera en integrerad typ.

Gäller för