By historical reasons, there are two old characters used to denote the boundary between lines (or paragraphs, depending in interpretation) for text files. One is "carriage return", "\r", and another one is "line feed", "\n" (also: "new line"). You can find them in the ASCII table:
ASCII — Wikipedia, the free encyclopedia[
^].
It's funny, but these characters mimic behavior of mechanical typewriter. The letters hits the paper pressed against the rubberized bar; the bar with the paper is mounted in the "carriage" (it "carries" it) which moves horizontally to move from one character position to the next one. When the line is complete, it moves all the way to the left. It corresponds to "\r", "carriage return". Then the bar rotates by one line, and it corresponds to "\n". These two operations are kept independent, because some typing tricks requires moving just the carriage to type over already typed text, and independent rotation of the bar, to print something on an arbitrary line. So these operations sneaked in computer notation, even though no printer actually used them the way the mechanical typewriter did.
In Unicode, there are different characters used for similar purposes, but "\r" and "\n" are used more often.
Worse, the rules for using these characters depend on the platform. Please see:
Newline — Wikipedia, the free encyclopedia[
^].
In .NET programs, in most cases (in fact, it also depends on purpose), you need to use platform-dependent object instead,
System.Environment.NewLine
:
Environment Class (System)[
^].
Still, if you copy one text file from one platform to another, on a target platform, you can get "non-native" use of new line characters. These days, this is not a big problem. The role of text files is reduced to the media for the file format where it does not matter, such as, say, HTML, ePUB, Open XML, and so on. On all platform, modern text handling software, including text editors, are designed to detect mismatch and fix it, "normalize".
—SA