Expression.NewArrayBounds Méthode

Définition

Crée un NewArrayExpression qui représente la création d'un tableau ayant un rang spécifié.

Surcharges

NewArrayBounds(Type, Expression[])

Crée un NewArrayExpression qui représente la création d'un tableau ayant un rang spécifié.

NewArrayBounds(Type, IEnumerable<Expression>)

Crée un NewArrayExpression qui représente la création d'un tableau ayant un rang spécifié.

NewArrayBounds(Type, Expression[])

Crée un NewArrayExpression qui représente la création d'un tableau ayant un rang spécifié.

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

Paramètres

type
Type

Type qui représente le type d'élément du tableau.

bounds
Expression[]

Tableau d'objets Expression à utiliser pour remplir la collection Expressions.

Retours

NewArrayExpression

NewArrayExpression dont la propriété NodeType est égale à NewArrayBounds et dont la propriété Expressions a la valeur spécifiée.

Exceptions

type ou bounds est null.

  • ou - Un élément de bounds est null.

La propriété Type d'un élément de bounds ne représente pas un type intégral.

Exemples

L’exemple suivant montre comment utiliser la méthode pour créer une arborescence d’expressions qui représente la création d’un tableau de chaînes dont le NewArrayBounds rang est 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)

Remarques

La Type propriété du résultat NewArrayExpression représente un type de tableau dont le classement est égal à la longueur et bounds dont le type d’élément est type.

La Type propriété de chaque élément de bounds doit représenter un type intégral.

S’applique à

NewArrayBounds(Type, IEnumerable<Expression>)

Crée un NewArrayExpression qui représente la création d'un tableau ayant un rang spécifié.

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

Paramètres

type
Type

Type qui représente le type d'élément du tableau.

bounds
IEnumerable<Expression>

IEnumerable<T> qui contient des objets Expression à utiliser pour remplir la collection Expressions.

Retours

NewArrayExpression

NewArrayExpression dont la propriété NodeType est égale à NewArrayBounds et dont la propriété Expressions a la valeur spécifiée.

Exceptions

type ou bounds est null.

  • ou - Un élément de bounds est null.

La propriété Type d'un élément de bounds ne représente pas un type intégral.

Exemples

L’exemple suivant montre comment utiliser la méthode pour créer une arborescence d’expressions qui représente la création d’un tableau de chaînes dont le NewArrayBounds rang est 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)

Remarques

La Type propriété du résultat NewArrayExpression représente un type de tableau dont le classement est égal à la longueur et bounds dont le type d’élément est type.

La Type propriété de chaque élément de bounds doit représenter un type intégral.

S’applique à