更新时间:2023-02-15 20:05:29
LAMBDA前pressions,像匿名方法,实际上是非常复杂的野兽。即使我们排除防爆pression
(.NET 3.5),仍然留下的很多的复杂性,并非最不重要的被捕获变量,这从根本上重新构造使用它们的code(你认为的变量成为编译器生成的类字段),带着几分雾里看花。
Lambda expressions, like anonymous methods, are actually very complex beasts. Even if we rule out Expression
(.NET 3.5), that still leaves a lot of complexity, not least being captured variables, which fundamentally re-structure the code that uses them (what you think of as variables become fields on compiler-generated classes), with a bit of smoke and mirrors.
因此,我丝毫不惊讶,你可以不会坐视使用它们 - 有一个的很多的编译工作(和类型一代幕后)的支持这个魔术。
As such, I'm not in the least surprised that you can't use them idly - there is a lot of compiler work (and type generation behind the scenes) that supports this magic.