Use replace with Environment.NewLine
myString = myString.Replace(System.Environment.NewLine, "replacement text")
As mentioned in other posts, if the string comes from another environment (OS) then you'd need to replace that particular environments implementation of new line control characters.
The solutions posted so far either only replace Environment.NewLine
or they fail if the replacement string contains line breaks because they call string.Replace
multiple times.
Here's a solution that uses a regular expression to make all three replacements in just one pass over the string. This means that the replacement string can safely contain line breaks.
string result = Regex.Replace(input, @"\r\n?|\n", replacementString);