Basic question . . .

L

Lauchlan M

How do I add a linefeed (ASCII character 10) to a string?

For example in Delphi I would do

TheString := PreString+ Chr(10) + PostString;

Where Chr(10) whacks in the ascii character for line feed / carriage return
and prestring and poststring are other strings.

How do I do this in C#?

Thanks!

Lauchlan M
 
C

Carl Fenley

It depends...

If you simply want to throw a carriage-return linefeed into a string for
display, simply use the \n code. For example:

string strTest = "This is the First Line.\nThis is the Second Line."

If you're writing to a file, you may find the NewLine property of the
TextWriter convenient.

- Carl
 
G

Greg Ewing [MVP]

Also, if you would like to write platform independent code, use
Environment.NewLine instead.
 

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