共用方式為


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(typeof(HashtableDebugView))]
class MyHashtable : Hashtable
<DebuggerDisplay("Count = {Count}"), DebuggerTypeProxy(GetType(MyHashtable.HashtableDebugView))> _
Class MyHashtable
    Inherits Hashtable

備註

參數 value 可包含大括號({ 和 })。 一對大括號內的文字會被評估為欄位、屬性或方法的名稱。 例如,下列 C# 程式碼在展開 MyTable 實例的調試顯示時,選取加號(+)會顯示「Count = 4」。

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

適用於