This question already has an answer here:
- Read random line from a file? c# 2 answers
Can anyone tell me how to read random line from txt file? I want to read random line from txt file and show only that line in textBox. Code examples would be great! Thanx in foward
The simplest solution is to read all the lines to memory and pick one randomly. Assuming that all the lines can fit in memory.
Here is a code sample: