In case of millions of line in a file, which API would be faster and can be parallelised?
File.ReadLines or Streamreader.Readline?
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalIn case of millions of line in a file, which API would be faster and can be parallelised?
File.ReadLines or Streamreader.Readline?
File.ReadLinesuses aStreamReaderinternallyStreamReaderis more powerful, but more verbose to use if you just want to iterate over all lines in a file.File.ReadLinesjust iterates over all lines in a file and none of the other stuff, but can do it in 1 line of codeBlockingCollectionclass or the TPL Dataflow library.