Standing on the shoulders of giants. RSS 2.0
# Thursday, January 22, 2009

This is not new, but something that helped me today.

When debugging, you can see the types in scope in the auto’s window:

Default debugger

This shows only the relevant information after expanding the view. One way of improving the experience is by implementing the ToString() method.

ToString method

While this helps a lot, this means you can’t use the ToString method for something else. Luckily in VS 2008 the DebuggerDisplayAttribute was introduced, this allows you to achieve the same effect and more.

DebuggerDisplayAttribute

And the code:

[System.Diagnostics.DebuggerDisplay("Date:{Date}, Value:{Value}", Name="{Name}")]
class Item
{
    public string Name { get; set; }

    public DateTime Date { get; set; }

    public int Value { get; set; }
}
Thursday, January 22, 2009 5:31:28 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [0] - Trackback
C# | Codesnippet
Comments are closed.
Ads
About
© Copyright 2010
Paul van Brenk
Sign In
newtelligence dasBlog 2.3.9074.18820
All Content © 2010, Paul van Brenk
DasBlog theme 'Business' created by Christoph De Baene (delarou)