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指定如何显示成员的值之一。

例外

示例

下面的代码示例演示如何使用 DebuggerBrowsableAttribute 特性指示调试器不显示属性的 Keys 根(属性名称),而是显示获取的数组 Keys 的元素。 该代码示例是 DebuggerDisplayAttribute 类中的一个较大示例的一部分。

[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

注解

此属性只能应用于属性和字段。

适用于