Export (0) Print
Expand All
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.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360DebuggerDisplayAttributeInitializes a new instance of the DebuggerDisplayAttribute class.
Top
  NameDescription
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360NameGets or sets the name to display in the debugger variable windows.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360TargetGets or sets the type of the attribute's target.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360TargetTypeNameGets or sets the type name of the attribute's target.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360TypeGets or sets the string to display in the type column of the debugger variable windows.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360ValueGets the string to display in the value column of the debugger variable windows.
Top
  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360EqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360FinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
NoteNote:

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)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.