Wednesday, March 28, 2012

string.split and Environment.NewLine question.

greetings...
i want to split a new line from an input text area and here's what i did
string.Split("\n \r ", ",");
the result, nothing happen...
then i tried this
string.Split(Environment.NewLine, ",");
and got the result what i wanted..
the question here is, why cant the 1st method work? whats wrong with it?The Environment.NewLine does not equal "\n \r "
The new line and carriage return characters are the wrong way round, and
cannot have any spaces between them.
Try this: "\r\n" (which is equal to Environment.NewLine)
"Asha" <Asha@.discussions.microsoft.com> wrote in message
news:984D487F-F0B9-462E-AFEA-BF1BE6BF4A3F@.microsoft.com...
> greetings...
> i want to split a new line from an input text area and here's what i did
> string.Split("\n \r ", ",");
> the result, nothing happen...
> then i tried this
> string.Split(Environment.NewLine, ",");
> and got the result what i wanted..
> the question here is, why cant the 1st method work? whats wrong with it?

0 comments:

Post a Comment