Question: Sorry if this is similar to an existing question - I did try looking!

Anyhow, I've got a program going as follows:

```
    static void Main(string[] args)
    {
        string temp;

        Console.WriteLine("question");
        temp = Console.ReadLine();

        if (temp == "a")
        {
            Console.WriteLine("Incorrect");
        }
        if (temp == "b")
        {
            Console.WriteLine("Incorrect");
        }
        if (temp == "c")
        {
            Console.WriteLine("Correct");
        }
        else
        {
            Console.WriteLine("Not a valid response");
        }

    }

```

And I'm trying to get it to *ignore invalid responses* until I give a valid response. If for example, I needed to press the key `a`, or `b`, or `c` but I pressed `d`, it would just tell me my answer *isn't a valid option* and wait until I gave a *valid response*.

Answer: 
Not sure if this is what you intend:

```
public static void Main()
        {
            Console.WriteLine("question");
            bool tryAgain;
            do
            {
                tryAgain = true;
                var key = Console.ReadKey();
                switch (key.KeyChar)
                {
                    case 'a':
                    case 'b':
                        Console.WriteLine();
                        Console.WriteLine("Incorrect");
                        tryAgain = false;
                        break;
                    case 'c':
                        Console.WriteLine();
                        Console.WriteLine("Correct");
                        tryAgain = false;
                        break;
                    default:
                        Console.Write("\b \b");
                        break;
                }
            } while (tryAgain);
        }

```

All inputs are ignored except valid inputs ('a', 'b', 'c') if you type 'd' inputs is ignored.

**UPDATE** this version works with Enter to confirm input:

```
public static void Main()
        {
            Console.WriteLine("question");
            bool tryAgain;
            bool enterPressed;
            char input = ' ';
            do
            {
                enterPressed = false;
                do
                {
                    tryAgain = true;
                    var key = Console.ReadKey();
                    switch (key.KeyChar)
                    {
                        case 'a':
                        case 'b':
                        case 'c':
                            input = key.KeyChar;
                            tryAgain = false;
                            break;
                        default:
                            Console.Write("\b \b");//Delete last char
                            break;
                    }
                } while (tryAgain);
                var confirmkey = Console.ReadKey();
                if (confirmkey.Key == ConsoleKey.Enter)
                {
                    enterPressed = true;
                    Console.WriteLine();
                }
                else
                {
                    Console.Write("\b \b"); //Delete last char
                }
            } while (!enterPressed);
            switch (input)
            {
                case 'a':
                case 'b':
                    Console.WriteLine("incorrect");
                    break;
                case 'c':
                    Console.WriteLine("correct");
                    break;
            }
        }

```
This is the textbook case for both do...while loops and switch/case statements. Asuming "a" is still a valid input:

```
bool validInput = false;

do{
  Console.WriteLine("question");
  string input = Console.ReadLine();

  switch(input){
    case "a":
      Console.WriteLine("Incorrect");
      validInput = true;
      break;
    //other cases and default omitted
  }

}while(!validInput);

```