using System;
using static System.Console;
class EnterUppercaseLetters
{
static void Main()
{
string userInput;
char letter;
const char QUIT = '!';
Write("Enter an uppercase letter: ");
userInput = ReadLine();
letter = Convert.ToChar(userInput);
while(letter != '!')
{
if(letter >= 'A' && letter <= 'Z')
{
WriteLine("OK");
}
else
WriteLine("Sorry - that was not an uppercase letter");
WriteLine("Enter an uppercase letter or {0} to quit", QUIT);
userInput = ReadLine();
letter = Convert.ToChar(userInput);
}
}
}
The code works as intended without brackets around my 'else' statements but creates an infinite loop with them. Am just wondering why that happens?