Random line in a text file. [C#]

Started by
10 comments, last by rob64464 19 years, 11 months ago
A better, and possibly slower, way might be if you read in a byte(character by character) at a time, and basically check for newline characters and count them up. I think that is the easiest way because some of the other methods may eliminate whitespaces for you and break at parts other than a new line.
Advertisement
quote:Original post by EbonySeraphim
A better, and possibly slower, way might be if you read in a byte(character by character) at a time, and basically check for newline characters and count them up. I think that is the easiest way because some of the other methods may eliminate whitespaces for you and break at parts other than a new line.

Nope, ReadLine is the superior way of doing this. Your suggestion is a hack.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]

This topic is closed to new replies.

Advertisement