The File class provides two static methods to read a text file in C#. The File.ReadAllText() method opens a text file, reads all the text in the file into a string, and then closes the file.
The following code snippet reads a text file in to a string.
// Read entire text file content in one string string text = File.ReadAllText(textFile);
Console.WriteLine(text);