【发布时间】:2009-08-04 06:50:45
【问题描述】:
我正在尝试在索引器类上做这样的事情:
[DebuggerDisplay("Debug: {_Items[index]}")]
public override string this[byte index]
但是,当调试器评估字符串时,值字段中的消息是“索引在当前上下文中不存在”。
有没有办法使用 DebuggerDisplay 属性来控制索引器类中单个元素的显示??
【问题讨论】:
我正在尝试在索引器类上做这样的事情:
[DebuggerDisplay("Debug: {_Items[index]}")]
public override string this[byte index]
但是,当调试器评估字符串时,值字段中的消息是“索引在当前上下文中不存在”。
有没有办法使用 DebuggerDisplay 属性来控制索引器类中单个元素的显示??
【问题讨论】:
试试
[DebuggerDisplay("Debug: {Items[{index}]}")]
【讨论】:
编辑:我真的对 OP 的问题没有信心。这是获取集合类型以在调试器中将其成员显示为列表的方法。
将以下属性放在“数组或集合”的字段或属性上,也许它会检查 IList<T> 的实现?
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
【讨论】: