I am trying to figure out an easy way remove \r\n from a string.
Example: text = "this.is.a.string.\r\nthis.is.a.string\r\n"
I tried:
text.Replace("\r\n", "")
and text.Replace("\r\n", string.Empty)
, but it doesn't work. \r\n
is still in the string...
The result should be: "this.is.a.string.this.is.a.string"
This reads better:
text = text.Replace(System.Environment.NewLine, string.Empty);
Strings in .NET are immutable and so you cannot change an existing string - you can only create a new one. The Replace
method returns the modified result, i.e.
text = text.Replace(System.Environment.NewLine, string.Empty);
text = JObject.Parse(text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With