Library for printing expressions

c# expression-trees

Question

I'm looking for the library which provides the expression printing functionality (from the lambdas converted to expression trees). In other words it should do similar job to parsing examples here, but should be obviously far more complete. Is anyone aware of such library?

Accepted Answer

If you want some textual representation of the expression and you don't care how exactly does it look like, you can use ToString(). All of the Expression types override this method.

For example, for the simple expression num => num < 5, ToString() returns num => (num < 5). But for more complicated expressions, it doesn't look like C# code anymore. For example, for num => num < Math.Pow(5,5), it returns num => (Convert(num) < Pow(5, 5)).



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow