开发者

Expression trees for code which doesn't type check

开发者 https://www.devze.com 2022-12-13 04:02 出处:网络
Is it possible to construct an expression tree in .NET 3.5 from code like Expression expr = () => (true + new object())

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 mi开发者_JS百科ssing something.

Obviously, such a tree can be constructed manually.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消