Insert LineFeed instead of CRLF
Simply write
sb.Append((char)10);
or more readable
sb.Append('\n');
even more readable
const char LF = '\n';
sb.Append(LF);
The Environment.NewLine
exists solely to differ between Windows-like line endings (\r\n
) and Unix-style line endings (\n
), so when writing text files and the like you don't have to bother which one to use (imagine you're running on Mono on Linux, then you want just \n
, which the Environment. NewLine
will contain as it is set by the runtime).
So when you know you always and only want a line feed character, simply put \n
in your code. It won't change.