Removing line breaks using C#

前端 未结 5 1984
时光取名叫无心
时光取名叫无心 2021-02-20 03:55

I am getting a string from database field named \'Description\' and it has line breaks. It looks like this:


Header of Items

Description goes here.This the

5条回答
  •  渐次进展
    2021-02-20 04:42

    For removal of all newlines, regardless of environment or badly formed strings, I think that this is the simplest option:

    var singleLineString = multilineString.Replace("\r", string.Empty).Replace("\n", string.Empty);
    

提交回复
热议问题