如何在vbnet中设置多行字符串变量

时间:2013-06-08 17:09:33

标签: .net vb.net string

我需要在变量中存储多行字符串:

dim str as string = "
    some words
    some words
    some
    words
"

如何?

4 个答案:

答案 0 :(得分:7)

无需使用类来插入新行,您可以这样做:

Dim Logo As String= <a><![CDATA[
___  ___        _  _    _  _  _              
|  \/  |       | || |  (_)| |(_)             
| .  . | _   _ | || |_  _ | | _  _ __    ___ 
| |\/| || | | || || __|| || || || '_ \  / _ \
| |  | || |_| || || |_ | || || || | | ||  __/
\_|  |_/ \__,_||_| \__||_||_||_||_| |_| \___|


 _____  _          _                         
/  ___|| |        (_)                        
\ `--. | |_  _ __  _  _ __    __ _           
 `--. \| __|| '__|| || '_ \  / _` |          
/\__/ /| |_ | |   | || | | || (_| |          
\____/  \__||_|   |_||_| |_| \__, |          
                              __/ |          
                             |___/           
]]></a>.Value

Console.WriteLine(Logo)

答案 1 :(得分:1)

VB.Net没有这样的功能,它将进入Visual Studio 2010。

查看Multiline strings in VB.NET了解变通方法

答案 2 :(得分:0)

像这样......

dim str as string = "some words" & vbCrlf & "some words" & vbCrlf & "some" & vbCrlf & "words"

或者尝试使用vbLf

答案 3 :(得分:0)

你可以像这样使用XML

dim vrstr as string = <s>
    some words
    some words
    some
    words
</s>