DebuggerBrowsableAttribute(DebuggerBrowsableState) 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 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)]
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
注解
此属性只能应用于属性和字段。