Lambda expression vs anonymous methods [duplicate]

隐身守侯 提交于 2019-12-02 18:59:23

Yes, lambda expressions are just very special anonymous methods.

However, there are some deep differences. Start with Eric Lippert's Lambda Expression vs. Anonymous Methods, Part One and continue to the rest of the series.

kelloti

The only difference is the lambda can be easily cast to Expression<Func<void>>. The delegates are purely just methods/closures, but the lambda an also be broken down into an expression tree:

Expression<Func<int, int>> expr = x => x*2; // Expression tree
Func<int, int> fun = x => x*2;              // function
delegate int MyDelegate(int x);
MyDelegate del = x => x*2;             // Same as function, delegate
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!