Afnan Bashir Afnan Bashir - 2 months ago 15
C# Question

Remove \r from string

I have some Html in string I have tried utmost to remove \r many times but fails.

text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");

Answer

You need to assign the result back to text, like:

text = text.Replace("\r\n", "").Replace("\r", "").Replace("\n", "");