Afnan Bashir Afnan Bashir - 28 days ago 7
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", "");
Comments