Remove newline charcters froma string

P

peelman

For some reason this is not working for me. How to remove all newline
characters from a string? I have tried:

myString.Replace ("\n", "");

I have also tried using TrimStart and TrimEnd methods from String
(using a char array with a '\n' in it), but to no avail.

Has it to do with the '\r' somewhere in there, or is there just an
easier way to this? I know this should not be hard.

Thanks in advance,

NC
 
K

Karl Seguin

myString = myString.Replace(System.Environment.NewLine, "");

Karl

P.S. - yes, it probably have something to do with \r
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top