Solved

newline in a string

Posted on 2007-12-06
8
945 Views
Last Modified: 2008-02-01
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
Comment
Question by:knowlton
  • 5
  • 3
8 Comments
 
LVL 22

Accepted Solution

by:
RedKelvin earned 500 total points
ID: 20424523
Hi, use

\n
0
 
LVL 5

Author Comment

by:knowlton
ID: 20424527
or:

Environment.NewLine
0
 
LVL 22

Expert Comment

by:RedKelvin
ID: 20424528
Oh, and there is this too

System.Environment.NewLine;

Open in new window

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Author Comment

by:knowlton
ID: 20424530
LOL ...  yep!
0
 
LVL 22

Expert Comment

by:RedKelvin
ID: 20424536
snap!

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

Open in new window

0
 
LVL 5

Author Comment

by:knowlton
ID: 20424558
Huh.......the newline is not "showing up" in the string.

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

What gives?
0
 
LVL 5

Author Comment

by:knowlton
ID: 20424589
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
 
LVL 5

Author Comment

by:knowlton
ID: 20424595
"This sentence will have a" + "<br><br>" + " line break in it"

produces:

This sentence will have a

line break in it
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question