Those who prefer reading this site through RSS now can also subscribe for updates to .NET Tips & Tricks Community.
The DebuggerBrowsable attribute determines if and how a field or property is displayed in the debugger variable windows. Let's review the following code example:
public class VehicleSeries
{
private string _name;
public string Name
get { return _name; }
set { _name = value; }
}
private List<string> _vehicles = new List<string>();
public List<string> Vehicles
get { return _vehicles; }
set { _vehicles = value; }
The resulting display within the debugger is shown below:
Now lets remove duplicate information and show constituent vehicles by adding a few DebuggerBrowsable attributes:
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
This results in the following view in the debugger:
P.S. Also take a look at a tip "Use DebuggerDisplay attribute for a better debugger experience".