I recently came across this gem on Hatim’s Development Blog. It’s a post titled 5 Very Useful C# Attributes.
I’m really impressed with his example of the DebuggerDisplayAttribute. Very useful if you don’t want to keep drilling down while debugging.
DebuggerDisplayAttribute
Namespace: System.Diagnostics
Usage: The DebuggerDisplayAttribute can be a sweet shortcut to avoid expanding the object to get to the value of a given property when debugging. All you have to do is mouse over the object and any property defined in the attribute will show up with it’s value.
Sample:
[DebuggerDisplay("ProductName = {ProductName},ProductSKU= {ProductSKU}")]
public class Product
{
public string ProductName { get; set; }
public string ProductSKU { get; set; }
}