This topic has not yet been rated - Rate this topic

DebuggerDisplayAttribute Class

Determines how a class or field is displayed in the debugger variable windows.

System.Object
  System.Attribute
    System.Diagnostics.DebuggerDisplayAttribute

Namespace:  System.Diagnostics
Assembly:  mscorlib (in mscorlib.dll)
[ComVisibleAttribute(true)]
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Delegate, AllowMultiple = true)]
public sealed class DebuggerDisplayAttribute : Attribute

The DebuggerDisplayAttribute type exposes the following members.

  Name Description
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 DebuggerDisplayAttribute Initializes a new instance of the DebuggerDisplayAttribute class.
Top
  Name Description
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 Name Gets or sets the name to display in the debugger variable windows.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 Target Gets or sets the type of the attribute's target.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 TargetTypeName Gets or sets the type name of the attribute's target.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 Type Gets or sets the string to display in the type column of the debugger variable windows.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 Value Gets the string to display in the value column of the debugger variable windows.
Top
  Name Description
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 Equals Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected method Supported by Silverlight for Windows Phone Supported by Xbox 360 Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected method Supported by Silverlight for Windows Phone Supported by Xbox 360 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 ToString Returns a string that represents the current object. (Inherited from Object.)
Top
Note Note:

The common language runtime attaches no semantics to this attribute. It is provided for use by source code debuggers.

The DebuggerDisplayAttribute constructor has a single argument: a string to be displayed in the value column for instances of the type. This string can contain braces ({ and }). The text within a pair of braces is evaluated as the name of a field, property, or method. For example, the following C# code causes "Count = 4" to be displayed when the plus sign (+) is clicked to expand the debugger display for an instance of MyHashtable.

[DebuggerDisplay("Count = {count}")]
class MyHashtable
{
    public int count = 4;
}

Attributes that are applied to properties referenced in the expression are not processed. For some compilers, a general expression may be allowed that has only implicit access to this reference for the current instance of the target type. The expression is limited; there is no access to aliases, locals, or pointers.

This attribute can be applied to the following:

  • Classes

  • Structures

  • Delegates

  • Enumerations

  • Fields

  • Properties

  • Assemblies

The Target property specifies the target type when the attribute is used at the assembly level. The Name property can contain a string similar to the one used in the constructor, with expressions enclosed in braces. The Type property can be set blank if the type should not be displayed in the data windows.

NoteNote:

The properties should be used only on type proxies.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ