✅ Prevent carriage return from being added in the new multi-line string literal?
How to prevent
\r
from being added in a multi-line string literal?
C# is adding a \r
after the \n
only in Windows. I know that Windows uses \n\r
to indicate new lines, but can i somehow disable that?8 Replies
C# does no interpretation of the characters inside your string
So, if the file literally has
\r\n
in the text there, that's what you getI'm not reading a file, i have a multiline string like this
And it is adding
\n\r
after First Line
I can prevent this by doing
But maybe there is a cleaner solutionno like
your source file has \r in it for the newlines in the string
oh
that... make sense
so C# preserves that \r
My bad then, any idea if that can be changed in Rider?
yeah, should be a button for line endings on the bottom right
I think
Yep just found it, changed it to LF instead lf CRLF, thank your very much 😅