Random line in a text file. [C#]
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement