Search code examples
c#visual-studiodebuggervisualizer

Is there anything simple for debugger visualizers in C# that's analogous to editing autoexp.dat for C++?


I have a class that has a few simple members I'm looking to expose to the debugger in Visual Studio 2010. I want to quickly glance over a list of these types and avoid all the drilling and expanding of the variable's value tree. I'm hoping there's something quick to go by analogous to editing autoexp.dat like in C++.


Solution

  • Override ToString() for your objects, or use DebuggerDisplay (thanks @gdir).

    If a C# object has an overridden ToString(), the debugger will call the override and show its result instead of the standard {}. Thus, if you have overridden ToString(), you do not have to use DebuggerDisplay. If you use both, the DebuggerDisplay attribute takes precedence over the ToString() override.