Reputation: 2104
How do I override and format string in ToString
method to get multiline debug message, when I mouse over some variable in debuger. Currently when I return multiline string (seperated by \r\n
), it still ends up in single line in debugger.
Upvotes: 3
Views: 2037
Reputation: 49290
You could write a debugger visualizer for your type. Depending on your needs this might be overkill of course.
As @dtb has kindly noted in a comment, there is a visualizer provided out of the box which might be sufficent for your needs:
There's a visualizer that shows text and honours line breaks. You can access it from the magnifying glass icon in the tooltip. It's just the tooltip that shows strings in C# string literal syntax
Upvotes: 7
Reputation: 12842
Consider using the DebuggerDisplay attribute, it offers more options.
Upvotes: 1
Reputation: 29243
Have a look at the DebuggerDisplayAttribute, which gives you more control over what is displayed in the debugger. Not sure it allows multi-line text, though.
Upvotes: 0
Reputation: 887937
The debugger windows strip newlines from values.
If you want to see the newlines, print the value in the Immediate Window.
Upvotes: 1