C# Learner <cs****@learner.here> wrote:
Gerald Baeck <ge****@baeck.at> wrote:
s = "AAAAAAAAAAAAAAAAAAAAA" + Environment.NewLine;
s += "BBBBBBBBBBBBBBBBBBBBBBB";
Here're a couple of notes about using "\r\n" instead:
<http://tinyurl.com/4pxg9>.
Also note that such string concatenation is inefficient. Using something
like the following would've been better:
s = "AAAAAAAAAAAAAAAAAAAAA" + Environment.NewLine +
"BBBBBBBBBBBBBBBBBBBBBBB";
This effects a single call to String.Concat, avoiding the unnecessary
creation of a temporary string object.
Alternatively, use
s = "AAAAAAAAAAAAAAAAAAAAA"+"\r\n"+
"BBBBBBBBBBBBBBBBBBBBBBB";
so that the compiler does all the concatenation, rather than the
runtime.
I'm slightly wary of using Environment.NewLine for text boxes - as I
understand it, it's really what the operating system sees as the
default newline string for files, which may not be what text boxes need
to use. (For instance, I'm not sure what a Mono port of TextBox would
use - it might use \r\n for compatibility with code developed on
Windows, but then that would break if you used Environment.NewLine...
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too