Expression.NewArrayBounds Methode

Definition

Erstellt eine NewArrayExpression, die das Erstellen eines Arrays mit dem angegebenen Rang darstellt.

Überlädt

NewArrayBounds(Type, Expression[])

Erstellt eine NewArrayExpression, die das Erstellen eines Arrays mit dem angegebenen Rang darstellt.

NewArrayBounds(Type, IEnumerable<Expression>)

Erstellt eine NewArrayExpression, die das Erstellen eines Arrays mit dem angegebenen Rang darstellt.

NewArrayBounds(Type, Expression[])

Erstellt eine NewArrayExpression, die das Erstellen eines Arrays mit dem angegebenen Rang darstellt.

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

Parameter

type
Type

Ein Type, der den Elementtyp des Arrays darstellt.

bounds
Expression[]

Ein Array von Expression-Objekten, mit denen die Expressions-Auflistung aufgefüllt wird.

Gibt zurück

NewArrayExpression

Ein NewArrayExpression, bei dem die NodeType-Eigenschaft gleich NewArrayBounds und die Expressions-Eigenschaft auf den angegebenen Wert festgelegt ist.

Ausnahmen

type oder bounds ist null.

- oder - Ein Element von bounds ist null.

Die Type-Eigenschaft eines Elements von bounds stellt keinen ganzzahligen Typ dar.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie Sie die NewArrayBounds Methode verwenden, um eine Ausdrucksstruktur zu erstellen, die ein Zeichenfolgenarray mit einer Rangfolge von 2 darstellt.

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

Hinweise

Die Type Eigenschaft des resultierenden NewArrayExpression Elements stellt einen Arraytyp dar, dessen Rang gleich der Länge bounds und deren Elementtyp ist type.

Die Type Eigenschaft jedes Elements muss bounds einen integralen Typ darstellen.

Gilt für

NewArrayBounds(Type, IEnumerable<Expression>)

Erstellt eine NewArrayExpression, die das Erstellen eines Arrays mit dem angegebenen Rang darstellt.

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

Parameter

type
Type

Ein Type, der den Elementtyp des Arrays darstellt.

bounds
IEnumerable<Expression>

Ein IEnumerable<T>, das Expression-Objekte enthält, mit denen die Expressions-Auflistung aufgefüllt werden soll.

Gibt zurück

NewArrayExpression

Ein NewArrayExpression, bei dem die NodeType-Eigenschaft gleich NewArrayBounds und die Expressions-Eigenschaft auf den angegebenen Wert festgelegt ist.

Ausnahmen

type oder bounds ist null.

- oder - Ein Element von bounds ist null.

Die Type-Eigenschaft eines Elements von bounds stellt keinen ganzzahligen Typ dar.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie Sie die NewArrayBounds Methode verwenden, um eine Ausdrucksstruktur zu erstellen, die ein Zeichenfolgenarray mit einer Rangfolge von 2 darstellt.

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

Hinweise

Die Type Eigenschaft des resultierenden NewArrayExpression Elements stellt einen Arraytyp dar, dessen Rang gleich der Länge bounds und deren Elementtyp ist type.

Die Type Eigenschaft jedes Elements muss bounds einen integralen Typ darstellen.

Gilt für