The DebuggerDisplayAttribute constructor has a single argument: a string to be displayed in the value column for instances of the type. This string can contain braces ({ and }). The text within a pair of braces is evaluated as the name of a field, property, or method. For example, the following C# code causes "Count = 4" to be displayed when the plus sign (+) is selected to expand the debugger display for an instance of MyHashtable.
[DebuggerDisplay("Count = {count}")]
class MyHashtable
{
public int count = 4;
} Attributes applied to properties referenced in the expression are not processed. For some compilers, a general expression may be allowed that has only implicit access to this reference for the current instance of the target type. The expression is limited; there is no access to aliases, locals, or pointers.
This attribute can be applied to the following:
-
Classes
-
Structures
-
Delegates
-
Enumerations
-
Fields
-
Properties
-
Assemblies
The Target property specifies the target type when the attribute is used at the assembly level. The Name property can contain a string similar to the one used in the constructor, with expressions enclosed in braces. The Type property can be set blank if the type should not be displayed in the data windows.
Note |
|---|
| The properties should only be used on type proxies. |
For more information of the use of this attribute in Visual Studio 2005, see Using DebuggerDisplay Attribute.