GotoExpression 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
무조건 점프를 나타냅니다. 여기에는 반환 문, break 및 continue 문 및 기타 점프가 포함됩니다.
public ref class GotoExpression sealed : System::Linq::Expressions::Expression
public sealed class GotoExpression : System.Linq.Expressions.Expression
type GotoExpression = class
inherit Expression
Public NotInheritable Class GotoExpression
Inherits Expression
- 상속
예제
다음 예제에서는 메서드를 사용하여 Goto 개체가 포함된 GotoExpression 식을 만드는 방법을 보여 줍니다.
// Add the following directive to your file:
// using System.Linq.Expressions;
// A label expression of the void type that is the target for the GotoExpression.
LabelTarget returnTarget = Expression.Label();
// This block contains a GotoExpression.
// It transfers execution to a label expression that is initialized with the same LabelTarget as the GotoExpression.
// The types of the GotoExpression, label expression, and LabelTarget must match.
BlockExpression blockExpr =
Expression.Block(
Expression.Call(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }), Expression.Constant("GoTo")),
Expression.Goto(returnTarget),
Expression.Call(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }), Expression.Constant("Other Work")),
Expression.Label(returnTarget)
);
// The following statement first creates an expression tree,
// then compiles it, and then runs it.
Expression.Lambda<Action>(blockExpr).Compile()();
// This code example produces the following output:
//
// GoTo
// "Other Work" is not printed because
// the GoTo expression transfers execution from Expression.GoTo(returnTarget)
// to Expression.Label(returnTarget).
' Add the following directive to your file:
' Imports System.Linq.Expressions
' A label expression of the void type that is the target for the GoToExpression.
Dim returnTarget As LabelTarget = Expression.Label()
' This block contains a GotoExpression.
' It transfers execution to a label expression that is initialized with the same LabelTarget as the GotoExpression.
' The types of the GotoExpression, label expression, and LabelTarget must match.
Dim blockExpr As BlockExpression =
Expression.Block(
Expression.Call(GetType(Console).GetMethod("WriteLine", New Type() {GetType(String)}), Expression.Constant("GoTo")),
Expression.Goto(returnTarget),
Expression.Call(GetType(Console).GetMethod("WriteLine", New Type() {GetType(String)}), Expression.Constant("Other Work")),
Expression.Label(returnTarget)
)
' The following statement first creates an expression tree,
' then compiles it, and then runs it.
Expression.Lambda(Of Action)(blockExpr).Compile()()
' This code example produces the following output:
'
' GoTo
' "Other Work" is not printed because
' the Return expression transfers execution from Expression.GoTo(returnTarget)
' to Expression.Label(returnTarget).
속성
| Name | Description |
|---|---|
| CanReduce |
노드를 더 간단한 노드로 줄일 수 있음을 나타냅니다. true를 반환하면 Reduce()를 호출하여 축소된 폼을 생성할 수 있습니다. (다음에서 상속됨 Expression) |
| Kind |
"이동" 식의 종류입니다. 정보 용도로만 제공됩니다. |
| NodeType |
이 Expression노드 형식을 반환합니다. |
| Target |
이 노드가 이동하는 대상 레이블입니다. |
| Type |
이 Expression 식이 나타내는 식의 정적 형식을 가져옵니다. |
| Value |
대상에 전달된 값이거나, 대상이 System.Void 형식인 경우 null입니다. |
메서드
| Name | Description |
|---|---|
| Accept(ExpressionVisitor) |
이 노드 형식에 대한 특정 방문 메서드로 디스패치합니다. 예를 들어 . 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(LabelTarget, Expression) |
제공된 자식을 사용하여 이와 같은 새 식을 만듭니다. 모든 자식이 같으면 이 식을 반환합니다. |
| VisitChildren(ExpressionVisitor) |
노드를 줄인 다음 축소된 식에서 방문자 대리자를 호출합니다. 노드를 축소할 수 없는 경우 메서드는 예외를 throw합니다. (다음에서 상속됨 Expression) |