Open sandboxFocus

Method Capture

Capture(dynamic?)

Creates a compile-time object that represents a run-time expression, i.e. the syntax or code, and not the result itself. The returned IExpression can then be used in run-time C# code thanks to the Value property. This mechanism allows to generate expressions that depend on a compile-time control flow.

Declaration
[CompileTime(true, null)]
public static IExpression Capture(dynamic? expression)
Parameters
Type Name Description
dynamic expression

A run-time expression, possibly containing compile-time sub-expressions. The expression cannot be dynamic. If you have a dynamic expression, do not call this method, but cast the dynamic expression to IExpression.

Returns
Type Description
IExpression
See Also