LambdaExpression.Compile Method

Definition

Produces a delegate that represents the lambda expression.

Overloads

Compile()

Produces a delegate that represents the lambda expression.

Compile(Boolean)

Produces an interpreted or compiled delegate that represents the lambda expression.

Compile(DebugInfoGenerator)

Produces a delegate that represents the lambda expression.

Compile()

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

Produces a delegate that represents the lambda expression.

C#
public Delegate Compile();

Returns

A Delegate that contains the compiled version of the lambda expression.

Remarks

The Compile method can be used to convert a LambdaExpression expression tree into the delegate that it represents.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Compile(Boolean)

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

Produces an interpreted or compiled delegate that represents the lambda expression.

C#
public Delegate Compile(bool preferInterpretation);

Parameters

preferInterpretation
Boolean

true to indicate that the expression should be compiled to an interpreted form, if it's available; otherwise, false.

Returns

A delegate that represents the compiled lambda expression described by the LambdaExpression object.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.6, 2.0, 2.1

Compile(DebugInfoGenerator)

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

Produces a delegate that represents the lambda expression.

C#
public Delegate Compile(System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator);

Parameters

debugInfoGenerator
DebugInfoGenerator

Debugging information generator used by the compiler to mark sequence points and annotate local variables.

Returns

A delegate containing the compiled version of the lambda.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1