How to eliminate ALL line breaks in string?

后端 未结 12 1782
傲寒
傲寒 2021-01-30 10:22

I have a need to get rid of all line breaks that appear in my strings (coming from db). I do it using code below:

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


        
12条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-30 11:13

    If you've a string say "theString" then use the method Replace and give it the arguments shown below:

    theString = theString.Replace(System.Environment.NewLine, "");

提交回复
热议问题