What is a quick way to force CRLF in C# / .NET?

前端 未结 6 1510
独厮守ぢ
独厮守ぢ 2020-12-08 13:38

How would you normalize all new-line sequences in a string to one type?

I\'m looking to make them all CRLF for the purpose of email (MIME documents). Ideally this w

6条回答
  •  感情败类
    2020-12-08 13:54

    input.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n")
    

    This will work if the input contains only one type of line breaks - either CR, or LF, or CR+LF.

提交回复
热议问题