DebuggerDisplayAttribute Class

DebuggerDisplayAttribute Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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


Namespace:  System.Diagnostics
Assembly:  mscorlib (in mscorlib.dll)

[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Delegate|AttributeTargets.Enum|AttributeTargets.Field|AttributeTargets.Property|AttributeTargets.Struct, AllowMultiple = true)]
public sealed class DebuggerDisplayAttribute : Attribute

The DebuggerDisplayAttribute type exposes the following members.

Public methodDebuggerDisplayAttributeInitializes a new instance of the DebuggerDisplayAttribute class.

Public propertyNameGets or sets the name to display in the debugger variable windows.
Public propertyTargetGets or sets the type of the attribute's target.
Public propertyTargetTypeNameGets or sets the type name of the attribute's target.
Public propertyTypeGets or sets the string to display in the type column of the debugger variable windows.
Public propertyValueGets the string to display in the value column of the debugger variable windows.

Public methodEqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)


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.


The properties should be used only on type proxies.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

© 2016 Microsoft