visual-studio-2015visual-studio-debuggingwatch-window

Visual Studio 2015 looking at arrays in the watch window


Say, I have an array of large objects I'm looking at. The object class being:

Class Box
  Public length As Double
  Public breadth As Double
  Public height As Double
  ...
  ...
  Public blah as blah
End Class

Normally I use the watch window and expand the objects out and check out the object property I am interested in...

So after running my code in the watch I'd have something like:

- box[0]
    length      12      double
    breadth     10      double
    height      5       double
    ...
    ...
    blah        x       blah
+ box[1]
+ box[2]
.
.
.
+ box[x]

however, I was curious if there was a way to only see those properties of each object instead of all the other properties I'm not interested in along with it. For example, if i only wanted to see the height of each object like:

- box[0]
    height      5       double
- box[1]
    height      3       double
- box[2]
   height      2       double
.
.
.
- box[x]        x       double

Is this possible with the watch window? or like the immediate window or..?

Thanks so much


Solution

  • Not sure if it counts a duplicate, per se, but one option might as answered in Can the watch window value of a List<> be customised?

    Alternatively, you can customize how the Watch window displays different objects. See: https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-visualizers-of-data?view=vs-2017

    (edit: previous version pointed to the NatVis, which is just for Native objects)