Given multiple lines and we have to write all lines into a text file.
File.WriteAllLines()
This is a method of "File class, which is used to write all lines in a text file.
Syntax:
void WriteAllLines(string filename);
Parameter(s):
- filename - name of the 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.