Share via


DebuggerDisplayAttribute(String) 建構函式

定義

初始化 DebuggerDisplayAttribute 類別的新執行個體。

public:
 DebuggerDisplayAttribute(System::String ^ value);
public DebuggerDisplayAttribute (string value);
public DebuggerDisplayAttribute (string? value);
new System.Diagnostics.DebuggerDisplayAttribute : string -> System.Diagnostics.DebuggerDisplayAttribute
Public Sub New (value As String)

參數

value
String

要顯示在型別執行個體之值資料行中的字串;空字串 ("") 會讓值資料行變成隱藏的資料行。

範例

下列程式代碼範例會在選取加號 (+) 時,顯示繼承Hashtable類別中的 Count 屬性值,以展開 實例MyHashtable的調試程序顯示。 您必須執行 類別中 DebuggerDisplayAttribute 提供的完整範例,才能查看結果。

[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(HashtableDebugView::typeid)]
ref class MyHashtable : Hashtable
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(HashtableDebugView))]
class MyHashtable : Hashtable
<DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(GetType(MyHashtable.HashtableDebugView))> _
Class MyHashtable
    Inherits Hashtable

備註

參數 value 可以包含大括弧 ({ 和 }) 。 一對大括號內的文字會評估為字段、屬性或方法的名稱。 例如,下列 C# 程式碼會在選取加號 (+) 時顯示 "Count = 4",展開偵錯工具顯示的 MyTable 執行個體。

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

適用於