DebuggerBrowsableAttribute(DebuggerBrowsableState) 建構函式

定義

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

public:
 DebuggerBrowsableAttribute(System::Diagnostics::DebuggerBrowsableState state);
public DebuggerBrowsableAttribute (System.Diagnostics.DebuggerBrowsableState state);
new System.Diagnostics.DebuggerBrowsableAttribute : System.Diagnostics.DebuggerBrowsableState -> System.Diagnostics.DebuggerBrowsableAttribute
Public Sub New (state As DebuggerBrowsableState)

參數

state
DebuggerBrowsableState

其中一個 DebuggerBrowsableState 值,指定顯示成員的方法。

例外狀況

state 不是其中一個 DebuggerBrowsableState 值。

範例

下列程式代碼範例示範如何使用 DebuggerBrowsableAttribute 屬性,指示調試程式不要顯示屬性的 Keys 根 (屬性名稱) ,但顯示取得的數位 Keys 元素。 此程式代碼範例是針對 類別提供的較大範例的 DebuggerDisplayAttribute 一部分。

[DebuggerBrowsable(DebuggerBrowsableState::RootHidden)]
property array<KeyValuePairs^>^ Keys
{
    array<KeyValuePairs^>^ get()
    {
        array<KeyValuePairs^>^ keys = gcnew array<KeyValuePairs^>(hashtable->Count);

        IEnumerator^ ie = hashtable->Keys->GetEnumerator();
        int i = 0;
        Object^ key;
        while (ie->MoveNext())
        {
            key = ie->Current;
            keys[i] = gcnew KeyValuePairs(hashtable, key, hashtable[key]);
            i++;
        }
        return keys;
    }
}
[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;
    }
}
<DebuggerBrowsable(DebuggerBrowsableState.RootHidden)> _
ReadOnly Property Keys as KeyValuePairs()
    Get
        Dim nkeys(hashtable.Count) as KeyValuePairs

        Dim i as Integer = 0
        For Each key As Object In hashtable.Keys
            nkeys(i) = New KeyValuePairs(hashtable, key, hashtable(key))
            i = i + 1
        Next
        Return nkeys
    End Get
End Property

備註

此屬性只能套用至屬性和欄位。

適用於