patterncsharpCritical
Replace Line Breaks in a String C#
Viewed 0 times
replacelinestringbreaks
Problem
How can I replace Line Breaks within a string in C#?
Solution
Use replace with
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.
Environment.NewLinemyString = myString.Replace(System.Environment.NewLine, "replacement text"); //add a line terminating ;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.
Code Snippets
myString = myString.Replace(System.Environment.NewLine, "replacement text"); //add a line terminating ;Context
Stack Overflow Q#238002, score: 831
Revisions (0)
No revisions yet.