如何在VS 2013的立即窗口中执行LINQ和/或foreach? [英] How to execute LINQ and/or foreach in Immediate Window in VS 2013?

查看:136
本文介绍了如何在VS 2013的立即窗口中执行LINQ和/或foreach?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试过程中探查当前状态时,即时窗口"是非常有用的工具.我了解到,通过使用问号,可以在其中做更多的工作,如本文中的 .

Immediate Window is fantastically useful tools when probing the current state during debugging process. I learned that by using the question mark, one can do a bit more in there as shown in this post.

但是,我仍然不知道如何在其中执行LINQ查询(包括 lambda表达式).我也没有执行 foreach 语句.

However, I still don't know how to execute LINQ queries there (including lambda expressions). I've also failed to execute a foreach statement.

执行以下语句时:

?(things.Select(thing=>thing.Id);)
?(foreach(var thing in things);)

我遇到这些错误:

表达式不能包含lambda表达式
无效的表达词"foreach"

Expression cannot contain lambda expressions
Invalid expression term 'foreach'

(如何)可以在立即窗口中执行这些操作?

(How) can I execute these in the Immediate Window?

VS Gallery 中也有一个工具,但据说它仅适用于VS05和VS08,大多数程序员在不久前就将其抛在后面了.我正在寻找适用于VS13和/或VS15的产品.

There's also a tool in VS Gallery but it's said that it only works for VS05 and VS08, which most programmers have left behind looong time ago. I'm looking for something applicable to VS13 and/or VS15.

推荐答案

根据Visual Studio 2015中提供的新功能,现在可以在监视/即时窗口中获得对调试lambda的支持:

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

调试器Windows中的Lambda表达式

Lambda Expressions in Debugger Windows

您现在可以在Watch,Instant和 C#和Visual Basic中的其他调试器窗口.

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

来源:

Visual Studio 2015 RTM

这篇关于如何在VS 2013的立即窗口中执行LINQ和/或foreach?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆