How to execute LINQ and/or foreach in Immediate Window in VS 2013?

无人久伴 提交于 2019-12-03 22:35:27

According to the new features available in visual studio 2015, support for debugging lambdas is now available in the watch/immediate window:

Lambda Expressions in Debugger Windows

You can now use lambda expressions in the Watch, Immediate, and other debugger windows in C# and Visual Basic.

Source:

Visual Studio 2015 RTM

In VS2015 you can use lambda expressions in the watch window and immediate window.

Just add the watch or type in the immediate window (While debugging and things is in scope):

things.Select(thing => thing.Id);

and you will get a list of results.

Here is a blog about this

Unfortunately it seems impossible to use lambda's from either the immidiate window or the watch window. The technical reason for this is probabaly that linq queries are usually converted to normal expressions and that somehow this requires a full compilation step instead of the trickery used by these two windows.

In case you didn't know the thing=>thing.Id part is a lambda expression.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!