How best to read a File into List

后端 未结 10 1271
盖世英雄少女心
盖世英雄少女心 2020-11-27 17:34

I am using a list to limit the file size since the target is limited in disk and ram. This is what I am doing now but is there a more efficient way?

readonly         


        
10条回答
  •  眼角桃花
    2020-11-27 17:47

    string inLine = reader.ReadToEnd();
    myList = inLine.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList();
    

    I also use the Environment.NewLine.toCharArray as well, but found that didn't work on a couple files that did end in \r\n. Try either one and I hope it works well for you.

提交回复
热议问题