I want to insert a while loop in the following code in order to insert more than one record.
The code output asks for Name and ID and then print them out in a text file.
Here is my code:
Console.Write(" Enter your ID: ");
int ID = int.Parse(Console.ReadLine());
Console.Write(" Enter your Name: ");
string Name = Console.ReadLine();
Console.WriteLine(" Thank you! you are logged in as " + Name + " " + ID);
StreamWriter sw = new StreamWriter("fileone.txt", true);
Console.SetOut(sw);
Console.WriteLine("Thank you! you are logged in as " + Name + " " + ID);
Console.Read();
sw.Close();
How can I use while loop in order to to let the program ask for another 10 records to enter?
Any answers would be appreciated.
Thanks in advance.
StreamWriter
objects on one file all the same time and didn't synchronize their write buffers in any way. – Ben Voigt Apr 25 at 15:22