Re: remove new line in constant
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Tue, 17 May 2005 00:36:12 +0100
ttan <ttan@xxxxxxxxxxxxxxxxxxxxxxxxx> 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 - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: remove new line in constant
- From: ttan
- Re: remove new line in constant
- References:
- remove new line in constant
- From: ttan
- remove new line in constant
- Prev by Date: Re: Why can't overloads take into account the return type.
- Next by Date: help guys... c# windows form
- Previous by thread: Re: remove new line in constant
- Next by thread: Re: remove new line in constant
- Index(es):
Relevant Pages
|