Alex Rivera | Logout

How to get ToString() to show up in Debug

Asked 2011-07-26T11:01:50.580
21

I'd like to get ToString() to display for a class under my control in debug mode.

It'd be nice if this was the first thing to show up when you hover over a variable with the mouse. Is there an attribute for this?

Edit
Report

1 Answer

10

There is DebuggerDisplayAttribute which lets you influence the display. It allows you to write fairly complex expressions to produce the debug output, although it is not recommended to do so.

However, if you have overriden ToString then the debugger is documented to display that by default. Maybe there's something wrong with the code?

answered 2011-07-26T11:05:19.247

Your Answer