C# Replace New Lines
October 29th, 2009If you know you’re working on the Windows platform and all data will come from Windows then to replace newlines using C#.NET we just use.
myString=myString.Replace(Environment.NewLine,"");
In all other cases it’s much safer to string together the Replace function to cover all possibilities.
myString=myString.Replace("\r", "").Replace("\n", "");