C# debugging: [DebuggerDisplay] or ToString()?

Using [DebuggerDisplay] is meant only for the debugger. Overriding ToString() has the “side effect” of changing the display at runtime.

This may or may not be a good thing.

Often, you want more info during debugging than your standard ToString() output, in which case you’d use both.

For example, in your case, the “ToString” implementation seems odd to me. I would expect a “Person” class ToString() implementation to just return the Name directly, not “Name = PersonsName”. However, during debugging, I might want that extra information.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)