DebuggerDisplayAttribute(String) 建構函式

定義

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

C#
public DebuggerDisplayAttribute (string value);
C#
public DebuggerDisplayAttribute (string? value);

參數

value
String

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

範例

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

C#
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(HashtableDebugView))]
class MyHashtable : Hashtable

備註

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

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

適用於

產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0