Hi,
Bjorn Abelli said:
...
I'm not sure I understand your sentence above.
Neither I do
I think it was a message I sent by mistake
, sorry for the mess, it wa
early in the morning and I had no coffee in my MemoryStream yet
Other posters in this thread say that the "concatenation" of NewLine
*will* be handled by the compiler, because it's not a variable, but a
constant (which also the documentation says in MSDN).
Well what happens then if you are running in an environment where NewLine is
different? , IF it was compiled AND concatenated in the string it will
display it wrongly in the new platform.
I just checked MSDN and it says textually ( A string containing "\r\n". )
Which IMO it's a mistake.
But as I just saw in another post of the OP , he is not using NewLine (which
is the correct way to do it) but vbCrLf which is indeed a constant
equivalent to "\r\n" , no idea why he posted in the C# NG when he was using
VB.net , but the post is relevant anyway.
Do you mean that the OP's use of the intermediate variable 'nl'
invalidates that?
Yes, if you use a variable you lose the posibility of the compiler
converting it to a literal, just think, what happens if the variable is
changed from another thread? The compiler cannot assure this so I bet it
will not create the literal concatenating all the strings, it will instead
create a bunch of literals.
Shouldn't the compiler be able to optimize away that anyway?
No, for the reason I mentioned above, as soon as you include a variable it
cannot optimize it. At least that is what I think, I haven't check it
though.
For the OP, it wasn't useless, as the query itself was logged (with the
line breaks)
You are right, if he logs it it does has a difference, I missed that part.