Visual Studio 立即窗口:如何查看前 100 个以上的项目
我试图在 Visual Studio 2005 的立即窗口中查看具有超过 300 个属性的对象的属性。仅显示前 100 个项目,后跟以下标题:
< More... (The first 100 of 306 items were displayed.) >
我试图查看其余项目,但不能'搞不懂。
我意识到我可以在“监视”窗口中看到这些,但这并不相同。
I am trying to see the properties of an object with over 300 properties in the Immediate Window of Visual Studio 2005. Only the first 100 items are displayed, followed by this caption:
< More... (The first 100 of 306 items were displayed.) >
I am trying to see the rest of the items, but can't figure it out.
I realize that I could see these in a Watch window, but that's not the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果将对象添加到监视窗口,请展开属性以便显示所有内容。然后Ctrl+A并复制。然后,您可以粘贴到 Excel 中以获得有序的属性及其值列表。
If you add your object to the watch window, then expand the properties so that all are displayed. Then Ctrl+A and Copy. You can then paste in excel to get an organized list of properties and their values.
有时,在直接窗口中查看列表比在监视窗口中查看更有用。通过使用以下命令,您可以轻松地看到比前 100 个更多的结果:
这确实不需要很长时间编写并且效果很好 - 对我很有用。
更新:正如下面的评论所指出的,这个答案实际上是错误的,仅适用于集合,不适用于具有大量属性的对象。我将其留在这里,因为很多人似乎发现它很有用。
Sometimes its useful to see the list in the immediate window rather than looking in the watch window. You can easily see more results than the first 100 by using:
Which really doesn't take long to write and works well - was useful for me.
Update: As pointed out in the comments below, this answer is actually wrong and applicable ONLY to collections and NOT to objects with lots of properties. I'm leaving it here as lots of people seem to have found it useful.
即时窗口被设计为一个快速查看工具。如果您想查看更多详细信息,则必须在观察窗口或快速观察窗口中查看。
另一种选择是编写一个 Visual Studio AddIn,其操作方式与立即窗口类似,但有更多选项。
The immediate window was designed to be a quick view tool. If you want to see more detail, you will have to view it in either the Watch Window or the Quick Watch Window.
Another option is to write a Visual Studio AddIn that operates similarly to the Immediate Window, but has more options.
在像这样进行调试时,我总是创建一个扩展方法来将对象导出到 xml。它对于排除对象数据故障非常有用。这是我使用的:
它不是 100% 完整的证明,但大多数时候它是完美的。它将在应用程序目录中创建一个以对象名称作为文件名的 xml 文件。在立即窗口中,您只需键入对象名称,然后键入 .SerializeToXML()。
所以:myList.SerializeToXML()
I always create an extension method to export objects to xml when debugging like this. It's very useful for troubleshooting object data. Here is what I use:
It's not 100% full proof, but most of the time it is perfect. It will create an xml file in the application directory with the objects name as the file name. In the immediate window you can just type the object name then .SerializeToXML().
so: myList.SerializeToXML()
这是一个老问题,但要在运行时获取对象的属性和值,这里有一个使用 Quickwatch 窗口的更合理的解决方案:
按CTRL + A 和 CTRL + C 以选择并复制所有属性。您需要扩展那些包含值且非基本类型的类型。
粘贴到您最喜欢的编辑器。
Its an old question but to get the properties and values of an object during runtime a more reasonable solution with Quickwatch window is here:
Press CTRL + A and CTRL + C in order to select and copy all Properties. You need to expand those which contains values and are non primitive types.
Paste to your favorite editor.
在
Locals
面板上,您可以将其添加到监视窗口:并重命名它以投射或显示范围:
您还可以复制其指针地址并使用
调试 ->窗口 -> Memory
显示内存内容:另请参阅:
On the
Locals
panel, you can add it to the watch window:And rename it to cast it or show a range:
You can also copy its pointer address and use the
Debug -> Windows -> Memory
to show the memory contents:See also: