在vb.net字符串常量中嵌入换行符 [英] Embedding a newline in a vb.net string constant
问题描述
是否可以以相同的方式在字符串中嵌入换行常量
作为c#?我真的不想做这样的事情:
++ String.Format(" Line 1:{0}"& vbcrlf&" Line 2:{1} ,o,t)
我应该能够做什么
++ String.Format("第1行:{0} \\\
Line2:{2 }",o,t)
不是最好的例子,我确定,但在很多情况下它确实变得更糟?
那么,有没有在vb中这样做的方法,还是我被卡住了?我已经尝试了
谷歌搜索,但我找不到任何东西。
谢谢,
Andrew
是否可以以相同的方式在字符串中嵌入换行常量
作为c#?我真的不想做这样的事情:
++ String.Format(" Line 1:{0}"& vbcrlf&" Line 2:{1} ,o,t)
我应该能够做什么
++ String.Format("第1行:{0} \\\
Line2:{2 }",o,t)
不是最好的例子,我确定,但在很多情况下它确实变得更糟?
那么,有没有在vb中这样做的方法,还是我被卡住了?我已经尝试了
谷歌搜索但我找不到任何东西。
谢谢,
Andrew
而不是vbcrlf使用Environment.NewLine
-
Bits.Bytes
http://bytes.thinkersroom.com
问题是如何我把它嵌入到字符串中。
如果有一些关于这个env常数的魔法将会发生这种情况,我想我还需要一些照明。
// Andrew
Rad [Visual C#MVP]写道:
On 2006年12月6日10:08:48 -0800,Andrew Backer写道:
是否可以以相同的方式在字符串中嵌入换行常量
为c#?我真的不想做这样的事情:
++ String.Format(" Line 1:{0}"& vbcrlf&" Line 2:{1} ,o,t)
我应该能够做什么
++ String.Format("第1行:{0} \\\
Line2:{2 }",o,t)
不是最好的例子,我确定,但在很多情况下它确实变得更糟?
那么,有没有在vb中这样做的方法,还是我被卡住了?我已经尝试了
谷歌搜索但我找不到任何东西。
谢谢,
Andrew
而不是vbcrlf使用Environment.NewLine
-
Bits.Bytes
http://bytes.thinkersroom.com
Andrew Backer写道:
是否可以以相同的方式在字符串中嵌入换行符
作为c#?我真的不想做这样的事情:
++ String.Format(" Line 1:{0}"& vbcrlf&" Line 2:{1} ,o,t)
我应该能够做什么
++ String.Format("第1行:{0} \\\
Line2:{2 }",o,t)
不是最好的例子,我确定,但在很多情况下它确实变得更糟?
那么,有没有在vb中这样做的方法,还是我被卡住了?我已经尝试了
谷歌搜索但我找不到任何东西。
谢谢,
Andrew
我能想到的唯一方法是:
String.Format("第1行:{0} {1}第2行:{2 }",o,vbcrlf,t)
Is it possible to embed a newline constant in a string in the same way
as c#? I really don''t want to do something like this:
++ String.Format("Line 1 : {0} " & vbcrlf & " Line 2 : {1}", o, t)
when I should be able to do
++ String.Format("Line 1 : {0}\nLine2 : {2}", o, t)
Not the best example, I am sure, but it does get worse in many cases?
So, is there a way to do this in vb, or am I stuck? I have tried
googling but I can''t find anything.
Thanks,
Andrew
On 6 Dec 2006 10:08:48 -0800, Andrew Backer wrote:
Is it possible to embed a newline constant in a string in the same way
as c#? I really don''t want to do something like this:
++ String.Format("Line 1 : {0} " & vbcrlf & " Line 2 : {1}", o, t)
when I should be able to do
++ String.Format("Line 1 : {0}\nLine2 : {2}", o, t)
Not the best example, I am sure, but it does get worse in many cases?
So, is there a way to do this in vb, or am I stuck? I have tried
googling but I can''t find anything.
Thanks,
AndrewInstead of vbcrlf use Environment.NewLine
--
Bits.Bytes
http://bytes.thinkersroom.com
The question is how do I embed it in the string.
If there is some magic regarding this the env constant that will make
this happen, I think I still need some illumination.
// Andrew
Rad [Visual C# MVP] wrote:On 6 Dec 2006 10:08:48 -0800, Andrew Backer wrote:
Is it possible to embed a newline constant in a string in the same way
as c#? I really don''t want to do something like this:
++ String.Format("Line 1 : {0} " & vbcrlf & " Line 2 : {1}", o, t)
when I should be able to do
++ String.Format("Line 1 : {0}\nLine2 : {2}", o, t)
Not the best example, I am sure, but it does get worse in many cases?
So, is there a way to do this in vb, or am I stuck? I have tried
googling but I can''t find anything.
Thanks,
Andrew
Instead of vbcrlf use Environment.NewLine
--
Bits.Bytes
http://bytes.thinkersroom.com
Andrew Backer wrote:Is it possible to embed a newline constant in a string in the same way
as c#? I really don''t want to do something like this:
++ String.Format("Line 1 : {0} " & vbcrlf & " Line 2 : {1}", o, t)
when I should be able to do
++ String.Format("Line 1 : {0}\nLine2 : {2}", o, t)
Not the best example, I am sure, but it does get worse in many cases?
So, is there a way to do this in vb, or am I stuck? I have tried
googling but I can''t find anything.
Thanks,
AndrewThe only way I can think of is:
String.Format("Line 1 : {0}{1}Line2 : {2}", o, vbcrlf, t)
这篇关于在vb.net字符串常量中嵌入换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!