I had problemen with string literals and unit tests. On my PC Environment.NewLine was different from the buildserver. So test results where different for:
$"a{Environment.NewLine}b"
and
""" a b """
So I changed the second to:
""" a b """.UseEnvironmentNewLine();
using these extensions methods:
public static string UseUnixNewLine(this string value) => value.UseSpecificNewLine("\n"); public static string UseWindowsNewLine(this string value) => value.UseSpecificNewLine("\r\n"); public static string UseEnvironmentNewLine(this string value) => value.UseSpecificNewLine(Environment.NewLine); public static string UseSpecificNewLine(this string value, string specificNewline) => Regex.Replace(value, @"(\r\n|\r|\n)", specificNewline);
If you want a \r\n as line end. Just do this:
string text = """ "header1";"header2" "value1";"value2" """.UseWindowsNewLine();
\n. They use whatever you typed. Your editor saved the source code with\ninstead of\r\n. Why do you want this though? What are you trying to do? You may not need\r\nat all."everywhere. Most applications will work just fine with ``n though. Excel certainly does.