Why does “\n” give a new line on Windows?

后端 未结 5 1989
轻奢々
轻奢々 2020-12-09 15:56

The line-break marker on Windows should be CR+LF whereas on Unix, it\'s just LF.

So when I use something like Console.Write(\"line1\\

5条回答
  •  我在风中等你
    2020-12-09 16:57

    This is just the standard behaviour of the underlying Windows console. A native C app will do exactly the same if you output 0x0A to the console.

    Of course, you should be using Environment.NewLine for your new lines. Environment.NewLine resolves to \r\n on Windows and \n on Unix like systems.

提交回复
热议问题