Open sandboxFocus

Method ToTypeOfExpression

ToTypeOfExpression(IType, bool)

Gets an IExpression representing 'typeof' expression for the given type.

Declaration
public static IExpression ToTypeOfExpression(this IType type, bool preferConstructedType = false)
Parameters
Type Name Description
IType type

The type.

bool preferConstructedType

When true and type is a generic type whose type arguments are its own type parameters (e.g. List<T> where T is List's type parameter), the generated typeof expression keeps the constructed form (e.g. typeof(List<T>)) instead of emitting the unbound generic type (e.g. typeof(List<>)). Use this only when the type parameters are in scope at the emission site. The default is false, which emits the unbound generic type for such inputs.

Returns
Type Description
IExpression

An IExpression representing typeof(type).