Given text, and we have to read text from the file using C# program.
File.ReadAllText()
This is a static method of "File" class, which is used to read all text from a file.
Syntax:
string File.ReadAllText(path);
Parameters:
- path - Filename with its location.
Return Value:
- string - Returned string that contains text which is written into text file..
-
Program:
Output
Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.
need an explanation for this answer? contact us directly to get an explanation for this answer