How to loop a Console App

Console.WriteLine("bla bla - enter xx to exit");
string line;
while((line = Console.ReadLine()) != "xx")
{
  string result = DoSomethingWithThis(line);
  Console.WriteLine(result);
}

while(true) {
  DisplayText();
  GetInput();
  DoCalculation();
  DisplayResult();
  DisplayText();
  GetInput();
}

The user can stop the program at any point with CTRL-C.

Is this what you meant?


You could wrap the whole body of your Main method in program.cs in a while loop with a condition that will always be satisfied.

E.g (in pseudo-code)

While (true)
{
   Body
}

Kindness,

Dan