When we must use DebuggerDisplay Attributes? What is the advantage of using this?
This article explains it well. You can use this attribute on your classes to display a more meaningful text when you debug. For example: Suppose you have a the following class:
[DebuggerDisplay("x = {x} y = {y}")]
MyClass
{
private int x;
private int y;
...
}
Once you debug an instance of MyClass in the Visual Studio debugger and you hover over it (or put it in the Watch Window, you no longer see "MyClass"
there but instead "x = 4 y = 5"
(assuming that x and y of this instance currently have this value. This is just an example you can do much more as the article explains it.