c# - Difference between using StreamReader.ReadLine and StreamReaderEnumerable -
is there difference between these 2 codes?
1. using (streamreader sr = new streamreader("filepath")) { while ((string line = sr.readline()) != null) { dosomething(); } } 2. foreach (string line in new streamreaderenumerable("filepath")) { if (line != null) { dosomething(); } } is there performance concern when using 1 on other, or functional identical during runtime?
according definition steamreaderenumerable, streamreader.readline() used. noticed custom solution solution uses same method. result, recommend using option 1 since not using linq work lines. way can avoid overhead of steamreaderenumerable class.
if did need use linq access lines, steamreaderenumerable class provide simple , robust way of doing so.
Comments
Post a Comment