i am new in C# and working on Console Applications now a days i wrote the following code :
Program.cs
using System;
using System.Collect
Try put the code that you will execute outside the main class in another method like
void execute()
{
Write();
string name = Console.ReadLine();
Write();
string name1 = Console.ReadLine();
Write();
string name2 = Console.ReadLine();
Write();
string name3 = Console.ReadLine();
Console.WriteLine("{0}, {1}, {2}, {3}",name,name1,name2,name3);
Console.WriteLine("enter \"y\" to restart the program and \"n\" to exit the Program");
string selectedOption = Console.ReadLine();
}
then in the main
static void Main(string[] args)
{
bool run = true
while(run){
execute()
Console.WriteLine("enter \"y\" to restart the program and \"n\" to exit the Program");
selectedOption = Console.ReadLine();
if (selectedOption == "n")
{
run = false;
}
}
}