TextReaderReadToEnd
TextReader.ReadToEnd is a method of System.IO.TextReader that reads all characters from the current position to the end of the text source and returns them as a single string. The reader is advanced to the end after the call.
Behavior: If the current position is already at the end, ReadToEnd returns an empty string. The method
Implementation and performance: In the base class, ReadToEnd is implemented by repeatedly calling Read and appending
Usage example: string content; using (var reader = new StreamReader(path)) { content = reader.ReadToEnd(); }
Asynchronous variant: The TextReader class also provides ReadToEndAsync, which returns Task<string> and can be awaited to
Related members: Read, ReadLine, ReadToEndAsync; See also TextReader, StreamReader, StringReader.