表达式树有用的一些实例是什么? [英] What are some instances in which expression trees are useful?
问题描述
还是只能用作代码的传输机制?
作为代码的执行机制很有用。使用解释器模式,可以直接解释表达式树。这是有用的,因为它非常容易和快速地实现。这样的口译员是普遍存在的,即使在似乎没有解释任何东西的情况下也是如此。用于打印嵌套结构。
I completely understand the concept of expression trees, but I am having a hard time trying to find situations in which they are useful. Is there a specific instance in which expression trees can be applied? Or is it only useful as a transport mechanism for code? I feel like I am missing something here. Thanks!
Or is it only useful as a transport mechanism for code?
It's useful as an execution mechanism for code. Using the interpreter pattern, expression trees can directly be interpreted. This is useful because it's very easy and fast to implement. Such interpreters are ubiquitous and used even in cases that don't seem to "interpret" anything, e.g. for printing nested structures.
这篇关于表达式树有用的一些实例是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!