How to split strings on carriage return with C#?

2019-01-21 16:17发布

I have an ASP.NET page with a multiline textbox called txbUserName. Then I paste into the textbox 3 names and they are vertically aligned:

  • Jason
  • Ammy
  • Karen

I want to be able to somehow take the names and split them into separate strings whenever i detect the carriage return or the new line. i am thinking that an array might be the way to go. Any ideas?

thank you.

7条回答
女痞
2楼-- · 2019-01-21 16:28

Take a look at the String.Split function (not sure of exact syntax, no IDE in front of me).

string[] names = txbUserName.Text.Split(Environment.Newline);
查看更多
登录 后发表回答