Replace Line Breaks in a String C#

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

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

17条回答
  •  逝去的感伤
    2020-11-22 11:42

    Why not both?

    string ReplacementString = "";
    
    Regex.Replace(strin.Replace(System.Environment.NewLine, ReplacementString), @"(\r\n?|\n)", ReplacementString);
    

    Note: Replace strin with the name of your input string.

提交回复
热议问题