VisualStudio debug Array tooltip class value

When debugging in VisualStudio...

When hovering the mouse over an array of custom class types and it lists the array by showing the full namespace path to the type for each array item, which is worthless.

I'm pretty sure I've seen an attribute you can put at the top of the class definition that will then show that property value instead. Can anyone point me in the right direction?

Answers


If you have an array of SomeType, you want to put the DebuggerDisplayAttribute on the SomeType class declaration.

[DebuggerDisplay("X={X}, Y={Y}, Count={Count}")]
public class SomeType { ... }

Then when you hover over a variable of type SomeType[], and expand the tooltip to see the elements, each one will show up as something like X=1, Y=13, Count=142.


Need Your Help

Avoiding copy-constructor / destructor when calling vector.push_back()

c++ copy-constructor move-semantics temporary-objects

MemRef is a small object that contains a pointer to memory, and a length. It's central to an optimization project to minimize string copying in a critical section. tokens is a deque<MemRef>...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.