NewArrayExpression 클래스

정의

새 배열을 만들고 선택적으로 새 배열의 요소를 초기화하는 동작을 나타냅니다.

public ref class NewArrayExpression : System::Linq::Expressions::Expression
public ref class NewArrayExpression sealed : System::Linq::Expressions::Expression
public class NewArrayExpression : System.Linq.Expressions.Expression
public sealed class NewArrayExpression : System.Linq.Expressions.Expression
type NewArrayExpression = class
    inherit Expression
Public Class NewArrayExpression
Inherits Expression
Public NotInheritable Class NewArrayExpression
Inherits Expression
상속
NewArrayExpression

예제

다음 예제에서는 문자열의 NewArrayExpression 1차원 배열을 만들고 초기화하는 것을 나타내는 개체를 만듭니다.

List<System.Linq.Expressions.Expression> trees =
    new List<System.Linq.Expressions.Expression>()
        { System.Linq.Expressions.Expression.Constant("oak"),
          System.Linq.Expressions.Expression.Constant("fir"),
          System.Linq.Expressions.Expression.Constant("spruce"),
          System.Linq.Expressions.Expression.Constant("alder") };

// Create an expression tree that represents creating and
// initializing a one-dimensional array of type string.
System.Linq.Expressions.NewArrayExpression newArrayExpression =
    System.Linq.Expressions.Expression.NewArrayInit(typeof(string), trees);

// Output the string representation of the Expression.
Console.WriteLine(newArrayExpression.ToString());

// This code produces the following output:
//
// new [] {"oak", "fir", "spruce", "alder"}
Dim trees As New System.Collections.Generic.List(Of System.Linq.Expressions.Expression) _
        (New System.Linq.Expressions.Expression() _
         {System.Linq.Expressions.Expression.Constant("oak"), _
          System.Linq.Expressions.Expression.Constant("fir"), _
          System.Linq.Expressions.Expression.Constant("spruce"), _
          System.Linq.Expressions.Expression.Constant("alder")})

' Create an expression tree that represents creating and  
' initializing a one-dimensional array of type string.
Dim newArrayExpression As System.Linq.Expressions.NewArrayExpression = _
    System.Linq.Expressions.Expression.NewArrayInit(Type.GetType("System.String"), trees)

' Output the string representation of the Expression.
Console.WriteLine(newArrayExpression.ToString())

' This code produces the following output:
'
' new [] {"oak", "fir", "spruce", "alder"}

다음 예제에서는 문자열의 NewArrayExpression 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)

설명

다음 표에서는 필요한 에 따라 를 만드는 데 사용할 수 있는 NewArrayExpression 다양한 팩터리 메서드를 NodeType 보여 줍니다.

NodeType 팩터리 메서드
NewArrayBounds NewArrayBounds
NewArrayInit NewArrayInit

속성

CanReduce

노드를 더 단순한 노드로 줄일 수 있는지 나타냅니다. true를 반환하면 Reduce()를 호출하여 축소된 형식을 만들 수 있습니다.

(다음에서 상속됨 Expression)
Expressions

NodeType 속성의 값이 NewArrayBounds이면 배열의 경계를 가져오고, NodeType 속성의 값이 NewArrayInit이면 새 배열의 요소를 초기화할 값을 가져옵니다.

NodeType

Expression의 노드 형식을 가져옵니다.

(다음에서 상속됨 Expression)
Type

Expression이 나타내는 식의 정적 형식을 가져옵니다.

Type

Expression이 나타내는 식의 정적 형식을 가져옵니다.

(다음에서 상속됨 Expression)

메서드

Accept(ExpressionVisitor)

이 노드 형식에 대한 특정 Visit 메서드로 디스패치합니다. 예를 들어 MethodCallExpressionVisitMethodCall(MethodCallExpression)을 호출합니다.

Accept(ExpressionVisitor)

이 노드 형식에 대한 특정 Visit 메서드로 디스패치합니다. 예를 들어 MethodCallExpressionVisitMethodCall(MethodCallExpression)을 호출합니다.

(다음에서 상속됨 Expression)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Reduce()

이 노드를 더 단순한 식으로 줄입니다. CanReduce가 true를 반환하면 유효한 식을 반환합니다. 이 메서드는 자체를 줄여야 하는 다른 노드를 반환할 수 있습니다.

(다음에서 상속됨 Expression)
ReduceAndCheck()

이 노드를 더 단순한 식으로 줄입니다. CanReduce가 true를 반환하면 유효한 식을 반환합니다. 이 메서드는 자체를 줄여야 하는 다른 노드를 반환할 수 있습니다.

(다음에서 상속됨 Expression)
ReduceExtensions()

알려진 노드 형식(확장 노드가 아님)으로 식을 줄이거나 이미 알려진 형식인 경우 식을 반환합니다.

(다음에서 상속됨 Expression)
ToString()

Expression의 텍스트 표현을 반환합니다.

(다음에서 상속됨 Expression)
Update(IEnumerable<Expression>)

제공된 자식을 사용하여 이 식과 같은 새 식을 만듭니다. 모든 자식이 같으면 이 식을 반환합니다.

VisitChildren(ExpressionVisitor)

노드를 줄인 다음 줄인 식에서 방문자 대리자를 호출합니다. 이 메서드는 노드를 줄일 수 없으면 예외를 throw합니다.

(다음에서 상속됨 Expression)

적용 대상