Is there a C# class that I can use to correctly convert the left or right Expressions of different types before using them in a BinaryExpression?

Viewed 61

The Expression tree which results from C# Expression Expression<Func<int, decimal>> f = (int i) => i + 1.0m ; has the correct Expression.Convert applied to the integer parameter i before it is added as left parameter to Expression.Add().

enter image description here

I want to follow the same conversion rules as C# when I build an expression tree manually. I of course can read the specs and write my own class to handle the conversions. But I was wondering if there is any in-built class that C# exposes to perform these conversions ? Using such a class(or method of this class) will guarantee that my conversions follow the same rules as C#.

0 Answers
Related