C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# TextReaderC# TextReader class is found in System.IO namespace. It represents a reader that can be used to read text or sequential series of characters. C# TextReader Example: Read All DataLet's see the simple example of TextReader class that reads data till the end of file. using System; using System.IO; namespace TextReaderExample { class Program { static void Main(string[] args) { using (TextReader tr = File.OpenText("e:\\f.txt")) { Console.WriteLine(tr.ReadToEnd()); } } } } Output: Hello C# C# File Handling by JavaTpoint C# TextReader Example: Read One LineLet's see the simple example of TextReader class that reads single line from the file. using System; using System.IO; namespace TextReaderExample { class Program { static void Main(string[] args) { using (TextReader tr = File.OpenText("e:\\f.txt")) { Console.WriteLine(tr.ReadLine()); } } } } Output: Hello C#
Next TopicC# BinaryWriter
|