Skip to main content
 首页 » 编程设计

c#之如何在索引器类上使用 DebuggerDisplay 属性

2024年02月24日18lautakyan007

我想在索引器类上做这样的事情:

    [DebuggerDisplay("Debug: {_Items[index]}")] 
    public override string this[byte index] 

但是,当调试器评估字符串时,值字段中的消息是“索引在当前上下文中不存在”。

有没有什么方法可以使用 DebuggerDisplay 属性来控制索引器类中单个元素的显示?

请您参考如下方法:

尝试

[DebuggerDisplay("Debug: {Items[{index}]}")]