string.split and Environment.NewLine question.

G

Guest

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?
 
D

Dan Bass

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)
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top