{{ !articles[0].partner.isSponsoringArticle ? "Platinum" : "Portal" }} Partner
dotnet,how-to,microsoft,tools,visual studio,debug,language,.net & windows,c-sharp

DebuggerDisplay Attribute in C#

The DebuggerDisplay is useful to quickly view the customized output of a class which in turn can display more meangful text during debugging.

Below is an example. Assume the class Student contains the following properties

class Student


   public string Name {get;set;}
   public string RegNo {get;set;} 

An instance of the student object is created and assigned values like below

public MainPage()


   Student name = new Student();

   name.Name = "Senthil Kumar";

   name.RegNo = "06PG0225";


During debugging, just mouse over on the instance “name”, you should see the data as shown in the screenshot below.

In the above screenshot, you will see a + icon followed by the instance name and the type.

Now, modify the class to include the DebuggerDisplay attribute like the one shown below.

Now, follow the same steps as described above. You should see a more meaningful data now :)

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks