newline in a string

In C#, I forget how you invoke a NewLine in the middle of a string -- so that the string after the newline appears on a -- uh -- new line.
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
RedKelvinConnect With a Mentor Commented:
Hi, use

\n
0
 
Tom KnowltonWeb developerAuthor Commented:
or:

Environment.NewLine
0
 
RedKelvinCommented:
Oh, and there is this too

System.Environment.NewLine;

Open in new window

0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Tom KnowltonWeb developerAuthor Commented:
LOL ...  yep!
0
 
RedKelvinCommented:
snap!

yeah, try this
string str = "this is a" + System.Environment.NewLine + "multi line string";

Open in new window

0
 
Tom KnowltonWeb developerAuthor Commented:
Huh.......the newline is not "showing up" in the string.

The string is being assigned to an asp:Label at runtime

What gives?
0
 
Tom KnowltonWeb developerAuthor Commented:
Huh.

These seem to work:

<br>

I guess I didn't think that would work in the middle of a string that is going into a Label.Text property.
0
 
Tom KnowltonWeb developerAuthor Commented:
"This sentence will have a" + "<br><br>" + " line break in it"

produces:

This sentence will have a

line break in it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.