use where method to replace lines with a string c# code example
Example 1: c sharp string replace
// You can use the function 'Replace()' to replace all instances
// of a string or character with a given string or character.
str = "Hello World!"
str.Replace('o', 'e');
// Output: "Helle Werld!"
Example 2: c# regex replace all line breaks
Regex.Replace((text ?? "").Replace("'", @"\'").Trim(), @"[\r\n]+", " ");