Replace Line Breaks in a String C#

后端 未结 17 876
失恋的感觉
失恋的感觉 2020-11-22 11:16

How can I replace Line Breaks within a string in C#?

17条回答
  •  渐次进展
    2020-11-22 11:53

    string s = Regex.Replace(source_string, "\n", "\r\n");
    

    or

    string s = Regex.Replace(source_string, "\r\n", "\n");
    

    depending on which way you want to go.

    Hopes it helps.

提交回复
热议问题