\ n不在连接代码中工作 [英] \n is not working in concatenation code

查看:44
本文介绍了\ n不在连接代码中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面代码中的新行(\ n)代码似乎不起作用:


textBox1.Text ="<%\ n" + comboBox1.SelectedItem +

"(\"" + textBox2.Text +" \")\ n%>" ;;

而不是给我:


<%

var1(" var2")

%> ;


它给了我:


<%var1(" var2")%>

>
我的代码中是否有错误?


谢谢,

JS


-

The new line (\n) code in the code below doesn''t seem to work:

textBox1.Text = "<%\n" + comboBox1.SelectedItem +
"(\"" + textBox2.Text + "\")\n%>";

Instead of giving me:

<%
var1("var2")
%>

it is giving me:

<%var1("var2")%>

Is there an error in my code?

Thanks,
J.S.

--

推荐答案

你好JS,

而不是在代码中连接\ n尝试使用

System.Environment.NewLine

ie


textBox1.Text =" hello" + System.Environment.NewLine +你好吗?


这应该适合你。


希望有帮助

Mark R Dawson。


" JS"写道:
Hi J.S,
instead of concatenating \n in your code try using
System.Environment.NewLine
i.e.

textBox1.Text = "hello" + System.Environment.NewLine + "how are you?"

this should work for you.

Hope that helps
Mark R Dawson.

"J.S." wrote:
下面代码中的新行(\ n)代码似乎不起作用:

textBox1.Text ="< ;%\\\
" + comboBox1.SelectedItem +
"(\"" + textBox2.Text +" \")\ n%>" ;;

而不是给予我:

<%
var1(" var2")
%>

它给了我:

<%var1(" var2")%>

我的代码中是否有错误?

谢谢,
JS

-
The new line (\n) code in the code below doesn''t seem to work:

textBox1.Text = "<%\n" + comboBox1.SelectedItem +
"(\"" + textBox2.Text + "\")\n%>";

Instead of giving me:

<%
var1("var2")
%>

it is giving me:

<%var1("var2")%>

Is there an error in my code?

Thanks,
J.S.

--



嗨Mark,


完美无缺!你知道为什么\\ n在这种情况下不起作用吗?


谢谢,

JS


-


" Mark R. Dawson" <马********* @ discussions.microsoft.com>在消息中写道

新闻:3E ********************************** @ microsof t.com ...
Hi Mark,

That worked perfectly! Do you know why \n doesn''t work in this context?

Thanks,
J.S.

--

"Mark R. Dawson" <Ma*********@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
你好JS,
而不是在代码中连接\ n尝试使用
System.Environment.NewLine


textBox1.Text =" hello" + System.Environment.NewLine +你好吗?

这应该对你有用。

希望有帮助
Mark R Dawson。
Hi J.S,
instead of concatenating \n in your code try using
System.Environment.NewLine
i.e.

textBox1.Text = "hello" + System.Environment.NewLine + "how are you?"

this should work for you.

Hope that helps
Mark R Dawson.



你好JS


在Windows系统上换行是\\\\ nn。一些控件和对象是宽容的,只会打破\ n,但不是全部。


Environment.NewLine在Windows系统上使用\\\\ n,\\ \\ n在其他系统上等。

On Sun,2005年8月21日15:42:10 +0200,JS < js*@nospam.com>写道:
Hi J.S.

On Windows systems a newline is \r\n. Some controls and objects are forgiving and will break the line with just \n, but not all of them.

Environment.NewLine uses \r\n on windows systems, \n on other systems etc.
On Sun, 21 Aug 2005 15:42:10 +0200, J.S. <js*@nospam.com> wrote:
嗨马克,

这完美无缺!你知道为什么\ n在这种情况下不起作用吗?

谢谢,
JS
Hi Mark,

That worked perfectly! Do you know why \n doesn''t work in this context?

Thanks,
J.S.




- < br $>
快乐的编码!

Morten Wennevik [C#MVP]



--
Happy coding!
Morten Wennevik [C# MVP]


这篇关于\ n不在连接代码中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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