DebuggerDisplay Attribute in C#
Join the DZone community and get the full member experience.
Join For Freethe 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 Senthil Kumar, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Integration Architecture Guiding Principles, A Reference
-
A Data-Driven Approach to Application Modernization
-
IntelliJ IDEA Switches to JetBrains YouTrack
-
Fun Is the Glue That Makes Everything Stick, Also the OCP
Comments