In C#, what's the difference between \n and \r\n?

后端 未结 8 1271
礼貌的吻别
礼貌的吻别 2020-12-14 00:37

As per subject...

8条回答
  •  执念已碎
    2020-12-14 00:44

    The Difference

    There are a few characters which can indicate a new line. The usual ones are these two:

    * '\n' or '0x0A' (10 in decimal) -> This character is called "Line Feed" (LF).
    * '\r' or '0x0D' (13 in decimal) -> This one is called "Carriage return" (CR).
    

    Different Operating Systems handle newlines in a different way. Here is a short list of the most common ones:

    * DOS and Windows
    

    They expect a newline to be the combination of two characters, namely '\r\n' (or 13 followed by 10).

    * Unix (and hence Linux as well)
    

    Unix uses a single '\n' to indicate a new line.

    * Mac
    

    Macs use a single '\r'.

    Taken from Here

提交回复
热议问题