问题描述
使用Visual Studio 2010 Professional,我有一个 ToString()
方法,如下所示:
public override string ToString()
{
returnsomething+\\\
+something;
}
因为有几个code $ c>的,每一个都很长,我想看看
某事
something
不幸的是,我看到
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ want want want want want want want want want want want want want want want want want want want want want want want want want want ?解决方案其实有一种方法。您可以在立即窗口中使用格式说明符来更改显示格式。如果您有一个带有回车符和换行符的字符串(\r\\\
),则可以使用'无引号'格式说明符来执行打印请求。
在立即窗口中键入:
?MyObj.ToString(),nq
和
\r\\\
将在立即窗口中导致换行符。 p>
有关格式说明符的更多信息,请参阅:
Using Visual Studio 2010 Professional, I have a
ToString()
method that looks like this:public override string ToString() { return "something" + "\n" + "something"; }
Because there are several "
something
"'s and each is long, I'd like to seesomething something
Sadly, I'm seeing
"something\nsomething"
Is there a way to get what I want?
解决方案Actually there is a way. You can use format specifiers in the immediate window to change the format of the display. If you have a string with carriage returns and linefeeds in it ("\r\n") you can follow the print request with the 'no quotes' format specifier.
In the immediate window type:
?MyObj.ToString(),nq
and the
\r\n
will cause newlines in the immediate window.For more info on format specifiers see:http://msdn.microsoft.com/en-us/library/e514eeby.aspx
这篇关于即时窗口中的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!