.NET/Visual Studio uses an object’s ToString() method to display the value of an object when viewing it in the debugger. I would like to display specific information, but since .ToString() is often used by the framework when converting an object to a string, I cannot do it by overriding ToString(). Is there an attribute I can use to tell the debugger to use a different method or property?
.NET/Visual Studio uses an object’s ToString() method to display the value of an object
Share
Use the
DebuggerDisplayAttribute[MSDN]. You supply it with a format string that references fields/properties within the class to display while debugging without having to mess withToString().It also works with methods: