Split text with '\r\n'

前端 未结 8 431
予麋鹿
予麋鹿 2020-12-28 12:42

I was following this article

And I came up with this code:

string FileName = \"C:\\\\test.txt\";

using (StreamReader sr = new StreamReader(FileNam         


        
8条回答
  •  粉色の甜心
    2020-12-28 13:06

    I took a more compact approach to split an input resulting from a text area into a list of string . You can use this if suits your purpose.

    the problem is you cannot split by \r\n so i removed the \n beforehand and split only by \r

    var serials = model.List.Replace("\n","").Split('\r').ToList();
    

    I like this approach because you can do it in just one line.

提交回复
热议问题