If the class is derived from a base class, or contains other objects within, you can drill down to see those values as well. Depending on the complexity of the object however, this can become tedious. This is especially true if there are a couple values that you always want to see when debugging.
To quickly see one or more properties on a class, you can do so using the DebuggerDisplay attribute in System.Diagnostics. If I add the following to MyBaseClass, I can view the value of X without expanding the DataTip. (The property to display is placed in braces.)
[DebuggerDisplay("The value of X is: {X}")]
If I derive a new class from MyBaseClass, I can set a DebuggerDisplay attribute that accesses values both from this class and the base.
[DebuggerDisplay("{X}, {Y}")]
class MyDerivedClass : MyBaseClass
{
private int _y;
public int Y
{
get { return _y; }
set { _y = value; }
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.