Expression<TDelegate>.Compile 메서드

정의

오버로드

Compile()

식 트리로 기술된 람다 식을 실행 코드로 컴파일하고 람다 식을 나타내는 대리자를 생성합니다.

Compile(Boolean)

식 트리로 설명되는 람다 식을 해석되거나 컴파일된 코드로 컴파일하고 람다 식을 나타내는 대리자를 생성합니다.

Compile(DebugInfoGenerator)

람다 식을 나타내는 대리자를 생성합니다.

Compile()

Source:
LambdaExpression.cs
Source:
LambdaExpression.cs
Source:
LambdaExpression.cs

식 트리로 기술된 람다 식을 실행 코드로 컴파일하고 람다 식을 나타내는 대리자를 생성합니다.

public:
 TDelegate Compile();
public TDelegate Compile ();
override this.Compile : unit -> 'Delegate
Public Function Compile () As TDelegate

반환

TDelegate

Expression<TDelegate>로 기술된 컴파일된 람다 식을 나타내는 TDelegate 형식의 대리자입니다.

예제

다음 코드 예제에서는 식 트리를 실행 하는 데 사용 하는 방법을 Compile 보여 줍니다.


// Lambda expression as data in the form of an expression tree.
System.Linq.Expressions.Expression<Func<int, bool>> expr = i => i < 5;
// Compile the expression tree into executable code.
Func<int, bool> deleg = expr.Compile();
// Invoke the method and print the output.
Console.WriteLine("deleg(4) = {0}", deleg(4));

/*  This code produces the following output:

    deleg(4) = True
*/

' Lambda expression as data in the form of an expression tree.
Dim expression As System.Linq.Expressions.Expression(Of Func(Of Integer, Boolean)) = Function(ByVal i) i < 5
' Compile the expression tree into executable code.
Dim deleg As Func(Of Integer, Boolean) = expression.Compile()
' Invoke the method and print the output.
MsgBox(String.Format("deleg(4) = {0}", deleg(4)))

' This code produces the following output:
'
' deleg(4) = True

설명

메서드는 Compile 런타임에 형식 TDelegate 의 대리자를 생성합니다. 해당 대리자를 실행하면 의 의미 체계에서 설명하는 동작이 Expression<TDelegate>있습니다.

메서드를 Compile 사용하여 식 트리의 값을 가져올 수 있습니다. 먼저 메서드를 사용하여 Lambda 식을 본문으로 포함하는 람다 식을 만듭니다. 그런 다음 를 호출 Compile 하여 대리자를 가져오고 대리자를 실행하여 식 값을 가져옵니다.

적용 대상

Compile(Boolean)

Source:
LambdaExpression.cs
Source:
LambdaExpression.cs
Source:
LambdaExpression.cs

식 트리로 설명되는 람다 식을 해석되거나 컴파일된 코드로 컴파일하고 람다 식을 나타내는 대리자를 생성합니다.

public:
 TDelegate Compile(bool preferInterpretation);
public TDelegate Compile (bool preferInterpretation);
override this.Compile : bool -> 'Delegate
Public Function Compile (preferInterpretation As Boolean) As TDelegate

매개 변수

preferInterpretation
Boolean

식이 해석된 형식으로 컴파일되어야 함을 나타내려면 true이고(사용 가능 시), 그러지 않은 경우 false입니다.

반환

TDelegate

Expression<TDelegate>에서 설명하는 컴파일된 람다 식을 나타내는 대리자입니다.

적용 대상

Compile(DebugInfoGenerator)

Source:
LambdaExpression.cs
Source:
LambdaExpression.cs
Source:
LambdaExpression.cs

람다 식을 나타내는 대리자를 생성합니다.

public:
 TDelegate Compile(System::Runtime::CompilerServices::DebugInfoGenerator ^ debugInfoGenerator);
public TDelegate Compile (System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator);
override this.Compile : System.Runtime.CompilerServices.DebugInfoGenerator -> 'Delegate
Public Function Compile (debugInfoGenerator As DebugInfoGenerator) As TDelegate

매개 변수

debugInfoGenerator
DebugInfoGenerator

컴파일러에서 시퀀스 위치를 표시하고 지역 변수에 주석을 추가하는 데 사용하는 디버깅 정보 생성기입니다.

반환

TDelegate

컴파일된 람다 버전을 포함하는 대리자입니다.

적용 대상