I believe I saw somewhere an attribute that, when applied to a class, would show the value of a property in intellisense. I'm not talking about XML comments. It looked something like this:
[SomeAttribute("Name = '{0}', Age = '{1}'", Name, Age)]
MyClass
Anyone know which Attribute I'm talking about?
It doesn’t make sense to “show a value in IntelliSense”, but I guess you mean in the debugger. In that case, the attribute you’re looking for is DebuggerDisplayAttribute
:
[DebuggerDisplay("Name = '{Name}', Age = '{Age}'")]
public class XYZ
{
public string Name;
public int Age;
}
Of course, you can also override the ToString()
method instead. In the absense of a DebuggerDisplayAttribute
, the debugger uses ToString()
. You should use DebuggerDisplayAttribute
only if you really need the implementation of ToString()
to be different (and insufficient for debugging).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With