Replace Line Breaks in a String C#

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Replace Line Breaks in a String C#

Message par Clippy »

Replace Line Breaks in a String C#
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: Replace Line Breaks in a String C#

Message par Clippy »

Use replace with `Environment.NewLine`

```
myString = 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](http://en.wikipedia.org/wiki/Newline).
Répondre

Revenir à « .NET & C# »