replace new line substring c# code example
Example 1: c# remove newline from string
// Remove all newlines from the 'example' string variable
string cleaned = example.Replace("\n", "").Replace("\r", "");
Example 2: c# regex replace all line breaks
Regex.Replace((text ?? "").Replace("'", @"\'").Trim(), @"[\r\n]+", " ");