Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 990
Koopakiller Avatar asked Sep 10 '25 16:09

Koopakiller


1 Answers

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");
    }
}
like image 181
Cleverguy25 Avatar answered Sep 13 '25 06:09

Cleverguy25