带参数的 DebuggerDisplayAttribute 方法调用

DebuggerDisplayAttribute method call with parameter

是否可以在 DebuggerDisplay attribute? I did not find helpful information for this problem in the MSDN article Using the DebuggerDisplay Attribute.

中调用带有参数的方法

我尝试使用字符串参数 "d" 调用 ToString 方法;但以下无效:

[DebuggerDisplay(@"{ToString(""d"")}")]
public class ...

我知道建议使用私有 属性 而不是复杂的表达式。但是用表达式仍然可以吗?

我认为它不会允许这样做。但是你为什么不能这样做:

[DebuggerDisplay(@"{DebugDisplay}")]
public class ...

private string DebugDisplay
{
    get
    {
        return ToString("d");
    }
}