DebuggerDisplayAttribute Makes Debugging Clearer

So today I came across another very useful blog post this one was about the attribute DebuggerDisplayAttribute. It allows you you to change what is output when you look at an object (especially useful in a collection of objects) to see something other than the value of what .ToString() displays which is generally just the name space and class definition which is less than optimal.

Example used in the article

[DebuggerDisplay(“Id = {Id}, Title = {Title}, Rating = {Rating}”)]
public class Movie
{
public int Id { get; set; }
public string Title { get; set; }
public float Rating { get; set; }
}

I think it’s pretty clear of the intent with this snippit but take a look at Greg Beech’s blog over at Tips & Tricks: Use DebuggerDisplayAttribute for easier debugging to see more detailed usage and some action screen shots.

BloggingContext.ApplicationInstance.CompleteRequest();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s