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?
 
RedKelvinCommented:
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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
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.