ユーザー入力が Y または N であることを確認し、そうでない場合は再度入力するように要求する単純な do-while ステートメントを作成したいと考えています。Y または N の場合、アプリは続行されます。これは私がこれまでに持っているものですが、私のアプリケーションはユーザー入力を求めるループに陥っています。C# の初心者 -- 助けてくれてありがとう。
string answer = "";
do
{
//Ask the user if they want to roll the dice
Console.WriteLine("Would you like to roll the dice (y or n)?");
//Get the user's response and validate that it is either 'y' or 'n'.
answer = Console.ReadLine();
} while (answer != "Y" || answer != "N");