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 🙂