Friday, March 6, 2009


During debugging sometime we fed up to see value of a property if it is deep inside a tree structure. We have to keep on click the “+” sign to expand the tree to reach our deep inside located property. On frequent debug it becomes a hectic task. DebuggerDisplayAttribute comes as a survivor.

DebuggerDisplayAttribute Class determines how a class or field is displayed in the debugger variable windows. This attribute 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 "MyTechnology = “.NET” " to be displayed when the cursor is placed on family variable.

Here I need to check the value assigned to Technology property frequently, so I declared that property in DebuggerDisplayAttribute. Futher the class containing that property should be decorated by DebuggerDisplayAttribute.

This attribute can be applied to the following:

The picture is shown below.