remove new line from string 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]+", " ");