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

Viewed 162847

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

9 Answers

You can insert one, or the other, or both:

  • \r\n inserts U+000DU+000A
  • \n\r inserts U+000AU+000D

If you intention is to indicate "the end of the line", different platforms, and different technologies, expect you to insert different things:

  • Windows: U+000DU+000A (i.e. \r\n)
  • HTTP: U+000DU+000A (i.e. \r\n)
  • HTML: U+000A (i.e. \n)
  • Unix: U+000A (i.e. \n)
  • Macintosh: U+000D (i.e. \r)
  • zOS: U+0085 (i.e. \x85)
Related