Create a program in C# to request lines from the user and write them in a text file.
Type lines until the user presses Enter.
public class WriteLinesTextFile
public static void Main(string args)
string fileName = "out.txt";
using (StreamWriter file = File.CreateText(fileName))
line = Console.ReadLine();
if (line.Length != 0)
while (line.Length != 0);
Practice C# anywhere with the free app for Android devices.
Learn C# at your own pace, the exercises are ordered by difficulty.
Your donations support our work and contribute to the maintenance of the app.
Own and third party cookies to improve our services. If you go on surfing, we will consider you accepting its use.