c# strip linefeed carriage return from string code example
Example 1: remove carriage returns from string c#
// Remove newlines from both sides of the 'example' string variable
string cleaned = example.Trim('\r', '\n');
Example 2: c# replace crlf
// Remove all newlines from the 'example' string variable
string cleaned = example.Replace("\n", "").Replace("\r", "");