Give a text file and we have to read it’s all lines using C# program.
File.ReadAllLines()
This is a method of "File class, which returns all lines (array of strings) from a text file.
Syntax:
String[] ReadAllLines(string filename);
Parameter(s):
- filename - name of the file.
Return value:
- This method return array of string, in which every element of array contains a line.
-
Program
Output
Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.