Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which Newline Character works with Both C# and HTML at a time?

Tags:

html

c#

c#-4.0

Hello I need Newline Character which works with both i.e C# and HTML I know That in C# We can use,

System.Environment.NewLine or "\r\n"

and in Html We can use,

<br/>

What is the alternative to this?

like image 310
XORG_99 Avatar asked Aug 31 '17 07:08

XORG_99


1 Answers

That depends on where you intend using that new line. For text files, use NewLine or \r\n. For HTML documents, use <br/>.

As you wrote in the comments:

I want to write log in log file and also send that log via mail as html body.

So you would need to seperate the two cases.

For breaking a line in your log file, use \r\n or System.Environment.NewLine.

For breaking a line in your HTML body, use <br/>.

For using the log as an HTML document body, you can simply use:

string body = logFileConent.Replace(@"\r\n", "<br/>");

Where logFileConent is a string variable holding your text file lines.

like image 91
Koby Douek Avatar answered Sep 24 '22 00:09

Koby Douek