Question

How do I check the type of a Parameter in an Expression Tree (and get the Expression Tree equivalent of a bool if it the right type)? If it were normal code, I would do this:

if(myObj is int)

I see there is a Expression.Convert method but this converts the object instead of just checking its type.

EDIT: I found the answer, you use a Expression.TypeIs

Was it helpful?

Solution

You can use the Expression.TypeIs method :

var isExpression = Expression.TypeIs(parameterExpression, typeof(SomeType));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top