Difference between \n and \r?

In terms of ascii code, it’s 3 — since they’re 10 and 13 respectively;-). But seriously, there are many: in Unix and all Unix-like systems, \n is the code for end-of-line, \r means nothing special as a consequence, in C and most languages that somehow copy it (even remotely), \n is the standard escape sequence for end of line (translated to/from … Read more

Carriage return and Line feed… Are both required in C#?

System.Environment.NewLine is the constant you are looking for – http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx which will provide environment specific combination that most programs on given OS will consider “next line of text”. In practice most of the text tools treat all variations that include \n as “new line” and you can just use it in your text “foo\nbar”. Especially … Read more

What is the difference between a “line feed” and a “carriage return”?

A line feed means moving one line forward. The code is \n.A carriage return means moving the cursor to the beginning of the line. The code is \r. Windows editors often still use the combination of both as \r\n in text files. Unix uses mostly only the \n. The separation comes from typewriter times, when you turned the wheel to move the paper to … Read more