Koopakiller
Koopakiller

Reputation: 2883

DebuggerDisplayAttribute method call with parameter

Is it possible to call a method with parameter(s) within the DebuggerDisplay attribute? I did not find helpful information for this problem in the MSDN article Using the DebuggerDisplay Attribute.

I try to call the ToString method with a string parameter "d"; but the following did not work:

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

I know it is recommended to use a private property instead of complex expressions. But is it nevertheless possible with an expression?

Upvotes: 4

Views: 672

Answers (1)

Cleverguy25
Cleverguy25

Reputation: 503

I don't think it will allow that. But why cant you do this:

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

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

Upvotes: 4

Related Questions