Ryan

Ryan

  • NA
  • 2
  • 0

Looping round a switch statement

Oct 19 2006 7:33 AM

Hi everyone, I'm a beginner to programming.  I have a simple query which I've been struggling with...
I'm not totally sure how to loop round the switch statement so that once one of the cases has been selected, the program loops back to the command line so it's ready for the next input command from the user.  Part of the code I'm using is below.

Thanks,
Ryan

Code:

Console.WriteLine("Please select one of the following options to sort the score table: Highest, Lowest, Average, Total");

string sortScore = Console.ReadLine();

while (sortScore != "exit")

{

   switch (sortScore)

  {

    case "Highest":

         //Do highest instructions here
        //Go back to top of while statement to input next command

    break;

    default:

        Console.WriteLine("Invalid command");

        Console.ReadLine();

    break;

}

}


Answers (1)