DebuggerDisplayAttribute(String) 建構函式

定義

初始化 DebuggerDisplayAttribute 類別的新執行個體。Initializes a new instance of the DebuggerDisplayAttribute class.

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

要顯示在型別執行個體之值資料行中的字串;空字串 ("") 會讓值資料行變成隱藏的資料行。The string to be displayed in the value column for instances of the type; an empty string ("") causes the value column to be hidden.

範例

下列程式碼範例會 Count Hashtable 在選取加號 (+) 來展開實例的偵錯工具顯示時,顯示繼承類別中的屬性值 MyHashtableThe following code example causes the value of the Count property from the inherited Hashtable class to be displayed when the plus sign (+) is selected to expand the debugger display for an instance of MyHashtable. 您必須執行類別中提供的完整範例 DebuggerDisplayAttribute 以查看結果。You must run the complete example, which is provided in the DebuggerDisplayAttribute class, to see the results.

[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參數可以包含大括弧 ( {和} ) 。The value parameter can contain braces ({ and }). 成對大括弧內的文字會評估為欄位、屬性或方法的名稱。The text within a pair of braces is evaluated as the name of a field, property, or method. 例如,下列 C# 程式碼會在選取加號 (+) 時顯示 "Count = 4",展開偵錯工具顯示的 MyTable 執行個體。For example, the following C# code causes "Count = 4" to be displayed when the plus sign (+) is selected to expand the debugger display for an instance of MyTable.

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

適用於