Reputation: 170755
Is it possible to construct an expression tree in .NET 3.5 from code like
Expression expr = () => (true + new object())
? It seems to be impossible, since "A compiler-generated expression tree is always rooted in a node of type Expression", but I may be missing something.
Obviously, such a tree can be constructed manually.
Upvotes: 1
Views: 122
Reputation: 42152
No it is not obvious that such a tree can be constructed manually. The expression the tree is representing is type-checked as it is being constructed. As such, what you ask is not possible and the answer is no.
Upvotes: 1