ttan <tt**@discussions.microsoft.com> wrote:
How do I remove new line in constant if I have a string like this
string st1 ="\abc\def";
That's not a valid string - \d isn't a valid escape sequence. It also
doesn't contain any newlines...
I use string trim but it doesn't work.
string st2;
for (int i = 0; i<st1.Lenght; i++)
{
st2 = st1.trim("\n".ToCharArray());
}
any idea?
That won't compile either, for various reasons. It's also entirely
unclear what purpose you expect the loop to serve. In future, it would
be well worth you producing a short but complete example which can be
compiled so that people can see your problem more clearly. See
http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
In this case, I believe your problem is that Trim only looks at the
start and end of the string. You should use Replace to replace all
occurrences.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too