Are Expression Trees a core language feature or a feature of the BCL object/library? Is it something that you can't build without the core language features of C#?
An expression tree is a special type of binary tree that is used to store algebraic expressions. In an expression tree, each internal node corresponds to the operator and each leaf node corresponds to the operand. Consider the algebraic expression given as: X = (a + b) - (c * d) .
Expression Trees represent code as a structure that you can examine, modify, or execute. These tools give you the power to manipulate code during run time. You can write code that examines running algorithms, or injects new capabilities.
Expression Tree is a special kind of binary tree with the following properties: Each leaf is an operand. Examples: a, b, c, 6, 100. The root and internal nodes are operators.
An expression tree is a kind of? Explanation: The expression tree is a binary tree. It contains operands at leaf nodes and remaining nodes are filled with operators. The operands and the operators can be arranged in any order (ascending, descending).
No, expression trees are not a language feature. They are usable from any .NET language so they cannot be C# specific. They are ordinary CLR types defined in a built-in assembly.
The construction through lambda expressions (and LINQ) is C# specific. But you can always construct an equivalent Expression
manually. The C# compiler itself does nothing more than to emit calls to the well-known Expression
static construction methods. You can inspect what the compiler emits by decompiling the binary with Reflector configured to an old .NET version.
Whether expression trees use .NET Framework internal APIs is an unrelated question, but I cannot think of any reason why they would need to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With