当我将鼠标悬停在调试器中的某个变量上时,如何覆盖和格式化 ToString
方法中的字符串以获取多行调试消息。目前,当我返回多行字符串(由 \r\n
分隔)时,它仍然在调试器中以单行结尾。
最佳答案
你可以写一个 debugger visualizer适合你的类型。根据您的需要,这当然可能有点矫枉过正。
正如@dtb 在评论中亲切指出的那样,开箱即用的可视化工具可能足以满足您的需求:
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
关于C# 覆盖 ToString 以便它在调试器中显示多行内容文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8562685/