C#C
C#β€’6mo ago
alek πŸ₯€

How can I make my program run a bool again? weird bug

Im making a simple 5 way Rock paper scissors game and at the end i have a line that goes

Console.Write("Would you like to play again (Y/N): ");
answer = Console.ReadLine();
answer = answer.ToUpper();

if (answer == "Y")
{
playAgain = true;
}
else
{
playAgain = false;
}

}
And after this i wanted it so that when the player types in anything else, it brings them to this:

Console.WriteLine("Thanks for playing!");
Console.WriteLine("Just write 'Y' to play again!");
answer1 = Console.ReadLine();
answer1 = answer1.ToUpper();

if (answer1 == "Y")
{
playAgain = true;
}
else
{ playAgain = false;
}
Console.ReadKey();
}
}
}
But whenever i put in Y or y it just ends the program.
I believe the error to be something with the first part with the if and else statement or my coding is just bad.
I want it to just on that last cw where its to play again after the thanks for playing that it brings me back to my bool which is the second image
I have no idea what im doing im new to c# so for now i removed it but id like to get it fixed thank you!!!
image.png
image.png
Was this page helpful?