Debugger Display Attribute in C#

The DebuggerDisplay attribute is available to customize the display of Class, Struct, Delegate, Enum, Field, Property and Assembly.

Let’s consider following Employee class, which has two properties as FirstName and LastName.


The normal way the class and its properties displayed is as follows.

To add DebuggerDisplay attribute, you need to refer to System.Diagnostics namespace.

The attribute takes string value as parameter.


The following code shows that, the Properties are used as parameters enclosed in curly braces.


The display of the class would change like following.


And the Property names display as usual.


However, we could add the attribute to one of the properties and see the result.


The following code shows that, at debug time, the Property display is changed using DebuggerDisplay attribute.


This is very useful, if you have many properties and you need to check few of them. It saves time to drill down.


Thanks for reading. Like Method Of Tried in Facebook.