Visual Studio Immediate window: how to see more than the first 100 items

35,093

Solution 1

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.

Solution 2

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.

Solution 3

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.

Solution 4

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

Share:
35,093
DOK
Author by

DOK

Senior web app developer specializing in ASP.Net MVC, C#, JavaScript (including various JS libraries), HTML5, CSS3 and SQL Server. I am having a great time learning and using all of the new techniques and technologies involved in web apps, responsive/adaptive design, and mobile- and tablet-friendly web apps. I generally work on projects because I have a strong preference for new development. I appreciate the opportunity to share knowledge with other professionals here on SO. I have some small demos at CodePen http://codepen.io/daphneokeefe/ and GitHub https://github.com/daphneokeefe

Updated on January 11, 2022

Comments

  • DOK
    DOK over 2 years

    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.