I found that this problem is not addressed in this knowledge base and decided to add the question and the answer to help others.
I am creating a TextReader
to read through a text file line by line using ReadLine
, which requires a termination check for the end of this stream.
TextReader TR = new TextReader("MyFile.txt");
while (!TR.EndOfStream) // fails to compile here
{
// do something
}
The EndOfStream does not exist for the TextReader class and this code will not compile.