HomeCSharpDebuggerDisplay Attribute in C#

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 🙂

Leave a Reply

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...