Hi,
I think (b) should be the fastest, but I wouldn't expect any significant
difference between (a) and (b) since Windows does efficient disk read
buffering behind the scenes.
I think (c) should be the slowest because of RegExp.
Anyway, it's all just guessing, why don't you try all the three approaches
and post the real result here? ;-)
--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
<ja*****@texeme.com> wrote in message
news:Nf********************@speakeasy.net...
Which would be faster for counting lines in a StreamReader:
(a) iterate through a file using .ReadLine() and adding to a counter, i++
(b) doing a .ReadToEnd() and then using an IndexOf() method to count the
occurances of \r\n
(c) doing a .ReadToEnd() and using a RegEx to count the number of
occurances
of \r\n
--
Texeme Textcasting Technology
http://www.texeme.com