DebuggerDisplayAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Enum Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Delegate, AllowMultiple:=True)> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class DebuggerDisplayAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Delegate, AllowMultiple=true)] [ComVisibleAttribute(true)] public sealed class DebuggerDisplayAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Enum|AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Delegate, AllowMultiple=true)] [ComVisibleAttribute(true)] public ref class DebuggerDisplayAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Delegate, AllowMultiple=true) */ /** @attribute ComVisibleAttribute(true) */ public final class DebuggerDisplayAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Delegate, AllowMultiple=true) ComVisibleAttribute(true) public final class DebuggerDisplayAttribute extends Attribute

DebuggerDisplayAttribute コンストラクタは、1 つの引数 (型のインスタンスの値列に表示される文字列) を持っています。この文字列には、中かっこ ({ と }) が含まれます。中かっこに囲まれたテキストは、フィールド、プロパティ、またはメソッドの名前と見なされます。たとえば、次の C# コードでは、正符号 (+) を選択して MyHashtable のインスタンスのデバッガ表示を展開すると、"Count = 4" が表示されます。
式で参照されるプロパティに適用する属性は処理されません。コンパイラによっては、対象の型の現在のインスタンスに対して、この参照への暗黙的なアクセスだけを持つ、一般的な式を使用できる場合があります。式には、エイリアス、ローカル、またはポインタへのアクセスを含めないという制限があります。
Target プロパティは、属性がアセンブリ レベルで使用される場合の対象の型を指定します。Name プロパティには、コンストラクタで使用される文字列のような文字列を中かっこで囲んだ式で含めることができます。型をデータ ウィンドウで表示しない場合は、Type プロパティを空白にすることができます。
![]() |
---|
この属性の Visual Studio 2005 での使用の詳細については、「DebuggerDisplay 属性の使用」を参照してください。

次のコード例を Visual Studio 2005 で参照して、DebuggerDisplayAttribute を適用した結果を確認できます。
using System; using System.Collections; using System.Diagnostics; using System.Reflection; //[assembly: DebuggerTypeProxy("MyHashtable.HashtableDebugView" ,TargetTypeName="MyHashtable")] class DebugViewTest { // The following constant will appear in the debug window for DebugViewTest. const string TabString = " "; // The following DebuggerBrowsableAttribute prevents the property following it // from appearing in the debug window for the class. [DebuggerBrowsable(DebuggerBrowsableState.Never)] public static string y = "Test String"; static void Main(string[] args) { MyHashtable myHashTable = new MyHashtable(); myHashTable.Add("one", 1); myHashTable.Add("two", 2); Console.WriteLine(myHashTable.ToString()); Console.WriteLine("In Main."); } } [DebuggerDisplay("{value}", Name = "{key}")] internal class KeyValuePairs { private IDictionary dictionary; private object key; private object value; public KeyValuePairs(IDictionary dictionary, object key, object value) { this.value = value; this.key = key; this.dictionary = dictionary; } } [DebuggerDisplay("Count = {Count}")] [DebuggerTypeProxy(typeof(HashtableDebugView))] class MyHashtable : Hashtable { private const string TestString = "This should not appear in the debug window."; internal class HashtableDebugView { private Hashtable hashtable; public const string TestString = "This should appear in the debug window."; public HashtableDebugView(Hashtable hashtable) { this.hashtable = hashtable; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public KeyValuePairs[] Keys { get { KeyValuePairs[] keys = new KeyValuePairs[hashtable.Count]; int i = 0; foreach(object key in hashtable.Keys) { keys[i] = new KeyValuePairs(hashtable, key, hashtable[key]); i++; } return keys; } } } }

System.Attribute
System.Diagnostics.DebuggerDisplayAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DebuggerDisplayAttribute クラスのページへのリンク