Quantcast
Viewing latest article 2
Browse Latest Browse All 4

Tip when using DebuggerDisplay in Dotnet/Visual studio

When debugging and watching an object one only sees the name of the type in the debugger.

1
MyProjectNamespace.Meeting

The quickest solution is to click the little plus sign or use the keyboard right arrow to show the properties. This is ok to do once or twice but doing this for every comparison is a waste of time at best.

Better then is to use SystemDiagnostics.DebuggerDisplay like so:

1
2
3
[DebuggerDisplay("ID:{ID}, UID:{UID}, Name:{Name}, Type:{this.GetType()}")]
public class Meeting : BaseClass {
...

to get

1
ID:1, UID:234abc, Name:XYZ, Type:MyProjectNamespace.Meeting

The Tip was to use {this.GetType()} in the argument of DebuggerDisplay.


Viewing latest article 2
Browse Latest Browse All 4

Trending Articles