即时窗口中的换行符 [英] Newlines in the Immediate Window

查看:124
本文介绍了即时窗口中的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用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>

有关格式说明符的更多信息,请参阅:
http://msdn.microsoft.com/en-us/library/e514eeby.aspx


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 see

something
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

这篇关于即时窗口中的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆