Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Expression Trees a core language feature of C#?

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#?

like image 256
user361633 Avatar asked Apr 26 '13 21:04

user361633


People also ask

What is expression tree in 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) .

What are expression trees used for?

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.

Is expression tree and binary tree same?

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.

What kind of tree is expression tree?

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).


1 Answers

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.

like image 132
usr Avatar answered Oct 30 '22 12:10

usr