string concatenation when assigning to variable

  • Thread starter Thread starter cgmoore
  • Start date Start date
C

cgmoore

Hi,

I think I read somewhere that

strVar = "one" & "andtwo" & "andthree"

is the equivalent of

strVar = "oneandtwoandthree"

and not the same as

strVar = "one"
strVar += "andtwo"
strVar += "andthree"

is this correct?

Thanks,
Gerald
 
Thanks, guys!

G

Phill. W said:
Correct.

The compiler optimises out string /literal/ concatenation.

However, for something like ...

s1 = "one"
s2 = "two"
s3 = "three"

s4 = s1 & s2 & s3

... you're back to square one, with all the action happening at run-time.

HTH,
Phill W.
 
[String concatenation]

In addition to the other replies: You can use tools like "ILDASM.EXE" or
Lutz Roeder's Reflector for taking a closer look at the IL emitted by the
compiler.
 

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

Back
Top