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

When inserting a new line character into a string I have usually done this:

str = "First line\nSecond line";

In C#, is this the standard practice? Should I also include the 'carriage return' character '\r'? Are there any difference between the following, and if so, what are they?

str = "First line\nSecond line";
str = "First line\r\nSecond line";

If using both 'carriage return' and 'line feed' is standard practice, is there a specific order and why?

Note: I read a few other posts on SO but didn't find an answer specific to .NET/C#.

Edit: After testing a little app, I didn't not see any difference between '\n' and '\n\r' or '\r\n'.

29
задан Luke Baulch 8 March 2011 в 02:46
поделиться