long strings in vb.net

X

xkeops

I have forgotten how vb.net deals with long strings, I know I used
this once but I don't remember.
Or was it C# ???

dim s as string = @"string1
string2
string3"

instead of

dim s as string = "string1" & _
string2" & _
string3"

So is it possible in vb.net to write a long string without breaking it
down with & _ ?

Thanks

xke
 
H

Herfried K. Wagner [MVP]

I have forgotten how vb.net deals with long strings, I know I used
this once but I don't remember.
Or was it C# ???

dim s as string = @"string1
string2
string3"

instead of

dim s as string = "string1" & _
string2" & _
string3"

So is it possible in vb.net to write a long string without breaking it
down with & _ ?

No, except in a single line. I believe you forgot the
'ControlChars.NewLine' in your VB sample above. VB doesn't support
something similar to C#'s verbatim string literals.
 
X

xkeops

So there is nothing in vb.net equivalent to sqlserver:

set @myVar = N'
word1
word2
word3
........'

?
 
P

Phill W.

dim s as string = "string1" & _
string2" & _
string3"

So is it possible in vb.net to write a long string without breaking it
down with & _ ?

No, but it doesn't matter because the /compiler/ recognises the
concatenation of string literals and bolts them together for you, under
the covers.

Dim s as String _
= "string1" _
& "string2" _
& "string3"

If you pull apart the generated ILCode, this is boiled down to the
single literal, "string1string2string3".

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top