Visual Studio 立即窗口:如何查看前 100 个以上的项目

发布于 2024-08-12 01:32:03 字数 231 浏览 11 评论 0原文

我试图在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

溺深海 2024-08-19 01:32:03

如果将对象添加到监视窗口,请展开属性以便显示所有内容。然后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.

风向决定发型 2024-08-19 01:32:03

有时,在直接窗口中查看列表比在监视窗口中查看更有用。通过使用以下命令,您可以轻松地看到比前 100 个更多的结果:

yourList.Skip(100).ToArray()

这确实不需要很长时间编写并且效果很好 - 对我很有用。

更新:正如下面的评论所指出的,这个答案实际上是错误的,仅适用于集合,不适用于具有大量属性的对象。我将其留在这里,因为很多人似乎发现它很有用。

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:

yourList.Skip(100).ToArray()

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.

梦幻的味道 2024-08-19 01:32:03

即时窗口被设计为一个快速查看工具。如果您想查看更多详细信息,则必须在观察窗口或快速观察窗口中查看。

另一种选择是编写一个 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.

給妳壹絲溫柔 2024-08-19 01:32:03

在像这样进行调试时,我总是创建一个扩展方法来将对象导出到 xml。它对于排除对象数据故障非常有用。这是我使用的:

public static void SerializeToXML(this object entity)
{
    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(entity.GetType());

    System.IO.StreamWriter file = new System.IO.StreamWriter(string.Format(@"{0}\{1}.xml", Directory.GetCurrentDirectory(), entity.GetType().Name));
    writer.Serialize(file, entity);
    file.Close();
}

它不是 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:

public static void SerializeToXML(this object entity)
{
    System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(entity.GetType());

    System.IO.StreamWriter file = new System.IO.StreamWriter(string.Format(@"{0}\{1}.xml", Directory.GetCurrentDirectory(), entity.GetType().Name));
    writer.Serialize(file, entity);
    file.Close();
}

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()

棒棒糖 2024-08-19 01:32:03

这是一个老问题,但要在运行时获取对象的属性和值,这里有一个使用 Quickwatch 窗口的更合理的解决方案:

  1. 在调试模式下打开 Quickwatch

Quickwatchwindow

  1. 输入您的变量名称并按 Enter

ModelExpression

  1. 按CTRL + A 和 CTRL + C 以选择并复制所有属性。您需要扩展那些包含值且非基本类型的类型。

  2. 粘贴到您最喜欢的编辑器。

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:

  1. Open Quickwatch during Debug mode

Quickwatchwindow

  1. Type in your Variablename and press Enter

ModelExpression

  1. 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.

  2. Paste to your favorite editor.

¢好甜 2024-08-19 01:32:03
  1. Locals面板上,您可以将其添加到监视窗口:

    “在此处输入图像描述"

  2. 并重命名它以投射或显示范围:

    “在此处输入图像描述"

  3. 您还可以复制其指针地址并使用调试 ->窗口 -> Memory 显示内存内容:

    “在此处输入图像描述"

另请参阅:

  1. 如何在 Visual Studio 中使用立即窗口?
  2. 如何在 Visual Studio 调试器中显示动态分配的数组?
  3. https://learn.microsoft。 com/en-us/previous-versions/visualstudio/visual-studio-2015/debugger/format-specifiers-in-cpp?view=vs-2015&redirectedfrom=MSDN
  1. On the Locals panel, you can add it to the watch window:

    enter image description here

  2. And rename it to cast it or show a range:

    enter image description here

  3. You can also copy its pointer address and use the Debug -> Windows -> Memory to show the memory contents:

    enter image description here

See also:

  1. How do you use the Immediate Window in Visual Studio?
  2. How to display a dynamically allocated array in the Visual Studio debugger?
  3. https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/debugger/format-specifiers-in-cpp?view=vs-2015&redirectedfrom=MSDN
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文