开发者

What is the character expression for a new line in C#?

I've got a text box control on a page and I want people to add URLs, one on each line and then split those URLs into an array.

So, I'm trying to split them on the newline character. I've tried:

.split(Environment.Newline)
.spli开发者_StackOverflowt('vbcrlf')
.split(vbcrlf)
.split((char)Environment.Newline)

but all to no avail. What am I doing wrong?


.split(new []{Environment.Newline}, StringSplitOptions.None);

This is because Environment.Newline is a string, so you must pass it in as an array of strings, as the function overload requires, also there needs to be a StringSplitOptions value included. This can either be StringSplitOption.None or StringSplitOption.RemoveEmptyEntries.


"\r\n" is the string representation

\r = carriage return \n = line feed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜