How to remove \r \n and other escape sequences in a string
c#, string, wpf
Solution
Try:
keyRight = keyRight.Replace("\r\n", "");
Problem
I have a string variable that I define as ``` String keyRight = new TextRange(rtb_KeyRight.Document.ContentStart, rtb_KeyRight.Document.ContentEnd).Text; ``` where rtb_KeyRight is a wpf richtextbox But when I debug my code, the escape sequences \r\n are added to my string. Doing this does not work: ``` keyRight.Replace("\r\n", ""); ``` Any ideas? Basically I'm just extracting the contents of the richtextbox and putting it in a string.