Sdílet prostřednictvím


Expression.NewArrayBounds Metoda

Definice

Vytvoří objekt NewArrayExpression , který představuje vytvoření pole, které má zadané pořadí.

Přetížení

Name Description
NewArrayBounds(Type, Expression[])

Vytvoří objekt NewArrayExpression , který představuje vytvoření pole, které má zadané pořadí.

NewArrayBounds(Type, IEnumerable<Expression>)

Vytvoří objekt NewArrayExpression , který představuje vytvoření pole, které má zadané pořadí.

NewArrayBounds(Type, Expression[])

Zdroj:
NewArrayExpression.cs
Zdroj:
NewArrayExpression.cs
Zdroj:
NewArrayExpression.cs
Zdroj:
NewArrayExpression.cs
Zdroj:
NewArrayExpression.cs

Vytvoří objekt NewArrayExpression , který představuje vytvoření pole, které má zadané pořadí.

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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
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
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")>]
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

Parametry

type
Type

A Type , který představuje typ prvku pole.

bounds
Expression[]

Pole Expression objektů, které se mají použít k naplnění Expressions kolekce.

Návraty

ANewArrayExpression, který má vlastnost rovna NewArrayBoundsNodeType a Expressions vlastnost nastavena na zadanou hodnotu.

Atributy

Výjimky

type nebo bounds je null.

nebo

bounds Prvek je null.

Vlastnost Type prvku bounds nepředstavuje celočíselný typ.

Příklady

Následující příklad ukazuje, jak použít metodu NewArrayBounds k vytvoření stromu výrazu, který představuje vytvoření řetězcové pole s pořadím 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)

Poznámky

Vlastnost Type výsledného NewArrayExpression představuje typ pole, jehož pořadí se rovná délce bounds a jehož typ prvku je type.

Vlastnost Type každého prvku bounds musí představovat celočíselný typ.

Platí pro

NewArrayBounds(Type, IEnumerable<Expression>)

Zdroj:
NewArrayExpression.cs
Zdroj:
NewArrayExpression.cs
Zdroj:
NewArrayExpression.cs
Zdroj:
NewArrayExpression.cs
Zdroj:
NewArrayExpression.cs

Vytvoří objekt NewArrayExpression , který představuje vytvoření pole, které má zadané pořadí.

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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
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
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")>]
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

Parametry

type
Type

A Type , který představuje typ prvku pole.

bounds
IEnumerable<Expression>

Objekt IEnumerable<T> obsahující Expression objekty, které se mají použít k naplnění Expressions kolekce.

Návraty

ANewArrayExpression, který má vlastnost rovna NewArrayBoundsNodeType a Expressions vlastnost nastavena na zadanou hodnotu.

Atributy

Výjimky

type nebo bounds je null.

nebo

bounds Prvek je null.

Vlastnost Type prvku bounds nepředstavuje celočíselný typ.

Příklady

Následující příklad ukazuje, jak použít metodu NewArrayBounds k vytvoření stromu výrazu, který představuje vytvoření řetězcové pole s pořadím 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)

Poznámky

Vlastnost Type výsledného NewArrayExpression představuje typ pole, jehož pořadí se rovná délce bounds a jehož typ prvku je type.

Vlastnost Type každého prvku bounds musí představovat celočíselný typ.

Platí pro