Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 980
  • Last Modified:

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.
0
Tom Knowlton
Asked:
Tom Knowlton
  • 5
  • 3
1 Solution
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now