While Loop that doesn't keep looping
c#, while-loop
Solution
I believe that it should be
while(cplayerSelection != 'R' || cplayerSelection != 'r')
You have to check for both the uppercase and lowercase letter since they do not have the same value.
Edit: Also change the cplayerSelection declaration to some other letter so the loop can actually be executed for the first time.
Also replace this line
cplayerSelection = (char)Console.Read();
with
cplayerSelection = Console.ReadKey().KeyChar;
Read the comment by Habib on this answer as to understand why.
Problem
For beginner practice I'm trying to create a simple loop that accepts a single character from the user, prints that character to the console and keeps doing that until the user enters 'R'. ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SimpleLoop { class Program { static void Main(string[] args) { char cplayerSelection = 'R'; while(cplayerSelection == 'R') { Console.WriteLine("Enter R, P, or S:"); cplayerSelection = (char)Console.Read(); Console.WriteLine(cplayerSelection); } } } } ``` How ever no matter what the user enters it only loops once end then exits. What do I need to change to continue the loop?